webwork转静态resultType
来源:互联网 发布:淘宝卖家不发货的原因 编辑:程序博客网 时间:2024/05/29 11:49
FreemarkerResult.class
public class FreemarkerResult extends WebWorkResultSupport
...{
protected ActionInvocation invocation;
protected Configuration configuration;
protected ObjectWrapper wrapper;
protected String filename; // 要转换的静态页面名称
protected String template; // 静态页面模板的路径
protected String filepath; // 文件夹名
protected String location;
private String pContentType = "text/html";
public void doExecute(String location, ActionInvocation invocation) throws IOException,
TemplateException
...{
this.location = location;
this.invocation = invocation;
this.configuration = getConfiguration();
this.wrapper = getObjectWrapper();
this.filename ="/"+ (String) conditionalParse(filename, invocation);
this.template = (String) conditionalParse(template, invocation);
this.filepath = ((String) conditionalParse(filepath, invocation))==null?"":((String) conditionalParse(filepath, invocation));
// 跳转页面的模板类
Template template = configuration.getTemplate(location, deduceLocale());
// 转换静台页面的的模板类
Template statictemplate = configuration.getTemplate(this.template, deduceLocale());
TemplateModel model = createModel();
String path = ServletActionContext.getServletContext().getRealPath(filepath)
+ File.separator;
this.delFile(path + filename);
Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(path + filename)));
if (preTemplateProcess(template, model))
...{
try
...{
// 在指定路径生成静态页面
statictemplate.process(model, out);
// 生成跳转的页面
template.process(model, getWriter());
} finally
...{
postTemplateProcess(template, model);
postTemplateProcess(statictemplate, model);
}
}
}
}
...{
protected ActionInvocation invocation;
protected Configuration configuration;
protected ObjectWrapper wrapper;
protected String filename; // 要转换的静态页面名称
protected String template; // 静态页面模板的路径
protected String filepath; // 文件夹名
protected String location;
private String pContentType = "text/html";
public void doExecute(String location, ActionInvocation invocation) throws IOException,
TemplateException
...{
this.location = location;
this.invocation = invocation;
this.configuration = getConfiguration();
this.wrapper = getObjectWrapper();
this.filename ="/"+ (String) conditionalParse(filename, invocation);
this.template = (String) conditionalParse(template, invocation);
this.filepath = ((String) conditionalParse(filepath, invocation))==null?"":((String) conditionalParse(filepath, invocation));
// 跳转页面的模板类
Template template = configuration.getTemplate(location, deduceLocale());
// 转换静台页面的的模板类
Template statictemplate = configuration.getTemplate(this.template, deduceLocale());
TemplateModel model = createModel();
String path = ServletActionContext.getServletContext().getRealPath(filepath)
+ File.separator;
this.delFile(path + filename);
Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(path + filename)));
if (preTemplateProcess(template, model))
...{
try
...{
// 在指定路径生成静态页面
statictemplate.process(model, out);
// 生成跳转的页面
template.process(model, getWriter());
} finally
...{
postTemplateProcess(template, model);
postTemplateProcess(statictemplate, model);
}
}
}
}
xwork.xml
<result-types>
<result-type name="staticview" class="msocweb.common.FreemarkerResult"></result-type>
</result-types>
<action name="staticViewAction" class="msocweb.sitemanage_u.action.StaticViewAction">
<external-ref name="newsService">newsService</external-ref>
<result name="success" type="staticview">
<param name="location">websitemanage/success.ftl</param>
<param name="filename">$...{filename}</param>
<param name="template">index/newsdetail.ftl</param>
<param name="filepath">/static</param>
</result>
</action>
<result-type name="staticview" class="msocweb.common.FreemarkerResult"></result-type>
</result-types>
<action name="staticViewAction" class="msocweb.sitemanage_u.action.StaticViewAction">
<external-ref name="newsService">newsService</external-ref>
<result name="success" type="staticview">
<param name="location">websitemanage/success.ftl</param>
<param name="filename">$...{filename}</param>
<param name="template">index/newsdetail.ftl</param>
<param name="filepath">/static</param>
</result>
</action>
- webwork转静态resultType
- WebWork 自定义resultType
- Webwork生成静态文件的简单方法
- webwork转struts
- WebWork
- WebWork
- WEBWORK
- webwork
- WebWork
- webwork
- webwork
- webwork
- WebWork
- webwork
- webwork
- webwork
- webwork
- webwork
- 开启rewrite功能及检测示例
- Lucene基本知识
- flex入门1----环境搭建
- 对文件操作的一些方法
- 推荐46款免费软件
- webwork转静态resultType
- UML用例图概要
- flex拓扑图制作
- 一个很强大的Comparator生成器
- Web Service故障处理
- equals和==
- 另类使用
- c# exe 路径
- LINQ体验(1)——Visual Studio 2008新特性