Struts2中使用FreeMarker模板引用。
引用
峰峰 的 Struts2中使用FreeMarker模板
在WEBROOT目录下创建login.ftl模板文件<html>
<head>
<title></title>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″ />
</head>
<body>
<@s.form action=”GMBOPA.llbt”>
<@s.textfield label=”用户名:” name=”username”/>
</@s.form>
</body>
</html>
然后将struts.xml配置文件中的act
ion的result的type改成freemarker,注意区分大小写。 <?xml version=”1.0″ encoding=”UTF-8″ ?>
<!DOCTYPE struts PUBLIC
“-//Apache Software Foundation//DTD Struts Configuration 2.0//EN”
“http://struts.apache.org/dtds/struts-2.0.dtd“>
<struts>
<package name=”login” extends=”struts-default”>
<interceptors>
<interceptor name=”parameterInterceptor” />
</interceptors><act
ion name=”GMBOPA” method=”operationProcessor”>
<result name=”error”>/error.jsp</result>
<result name=”success” type=”freemarker”>/${retPage}</result>
<interceptor-ref name=”defaultStack” />
<interceptor-ref name=”parameterInterceptor” />
</action>
</package>
</struts>