开发者

Custom template engine for struts2

I want to create a custom template engine like velocity or freemarker which will be used in struts 2 based application. Why I don't want to use any of the available template engines is because, I want to keep the HMTL fixed and editable by dreamweaver means no struts tags or JSTL. The 开发者_C百科values will be injected with Xpath or simple string replacement of values of existing HTML tags. I require:

plain HTML + some configuration (properties/xml) + data =>

HTML populated with data + some dynamically generated javascripts


1) Define a package with the name of your result type and the class that will be called when an action returns that result type.

<package name="default" namespace="/" extends="struts-default">
  <result-types>
    <result-type name="myResultType" class="com.awesome.MyResult"/> 
  </result-types>
  .... actions and other things...
</package>

2) Implement the Struts 2 result type class:

package com.awesome;
public class MyResult extends StrutsResultSupport{
  //1) read the the target file
  //2) process/transform the target file
  //3) write out the transformed file as the result
} 

There is a good description of this in "Apache Struts 2 web application Development" by Dave Newton. I know the above class isn't implemented but I bet you can find what you need from here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜