Struts2中使用FreeMarker模板引用



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配置文件中的action的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>

  <action 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>