webwork freemarker 整合后的使用方法!

需要继承FreemarkerManager类重写loadSettings方法
public class Test extends FreemarkerManager {

	@Override
	protected void loadSettings(ServletContext arg0, Configuration arg1) {
		// TODO Auto-generated method stub
		super.loadSettings(arg0, arg1);
		arg0.setAttribute("CacheMan", new CacheMan());
	}
}

在webwork.properties文件当中加上下列属性
webwork.freemarker.manager.classname = com.css.cache.Test

配置文件配置如下
<!DOCTYPE xwork
    PUBLIC "-//OpenSymphony Group//XWork 1.0//EN"
    "http://www.opensymphony.com/xwork/xwork-1.0.dtd">

<xwork>
	<package name="test" extends="webwork-default">
		<action name="test1" class="com.test.test1">
			<result name="success" type="freemarker">group/index.htm</result>
		</action>
    </package>
</xwork>

hello kugou!${key.getTime()}
${CacheMan.getObject("abc","123")}

你可能感兴趣的:(freemarker)