org.apache.struts2.views.freemarker
类 FreemarkerResult
java.lang.Object
org.apache.struts2.dispatcher.StrutsResultSupport
org.apache.struts2.views.freemarker.FreemarkerResult
- 所有已实现的接口:
- com.opensymphony.xwork2.Result, Serializable, StrutsStatics
public class FreemarkerResult
- extends StrutsResultSupport
Renders a view using the Freemarker template engine.
The FreemarkarManager class configures the template loaders so that the
template location can be either
- relative to the web root folder. eg
/WEB-INF/views/home.ftl
- a classpath resuorce. eg
/com/company/web/views/home.ftl
This result type takes the following parameters:
- location (default) - the location of the template to process.
- parse - true by default. If set to false, the location param will
not be parsed for Ognl expressions.
- contentType - defaults to "text/html" unless specified.
- writeIfCompleted - false by default, write to stream only if there isn't any error
processing the template. Setting template_exception_handler=rethrow in freemarker.properties
will have the same effect.
Example:
<result name="success" type="freemarker">foo.ftl</result>
- 另请参见:
- 序列化表格
FreemarkerResult
public FreemarkerResult()
FreemarkerResult
public FreemarkerResult(String location)
setFreemarkerManager
public void setFreemarkerManager(FreemarkerManager mgr)
setContentType
public void setContentType(String aContentType)
getContentType
public String getContentType()
- allow parameterization of the contentType
the default being text/html
doExecute
public void doExecute(String locationArg,
com.opensymphony.xwork2.ActionInvocation invocation)
throws IOException,
freemarker.template.TemplateException
- Execute this result, using the specified template locationArg.
The template locationArg has already been interoplated for any variable substitutions
this method obtains the freemarker configuration and the object wrapper from the provided hooks.
It them implements the template processing workflow by calling the hooks for
preTemplateProcess and postTemplateProcess
- 参数:
locationArg
- the location (jsp page, action, etc) to go to.invocation
- the execution state of the action.
- 抛出:
IOException
freemarker.template.TemplateException
setWriter
public void setWriter(Writer writer)
isWriteIfCompleted
public boolean isWriteIfCompleted()
- 返回:
- true write to the stream only when template processing completed successfully (false by default)
setWriteIfCompleted
public void setWriteIfCompleted(boolean writeIfCompleted)
- Writes to the stream only when template processing completed successfully