tiles和struts初步应用

类别:Java 点击:0 评论:0 推荐:

1,定义配置文件:

<?xml version="1.0" encoding="ISO-8859-1"?>
<component-definitions>
    <definition name="aDef" path="/layout.jsp">
        <put name="header" value="/header.jsp"/>
        <put name="footer" value="/footer.jsp"/>
        <put name="body" value="/aBody.jsp"/>
    </definition>
</component-definitions>

2,配置web.xml:

<servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.tiles.ActionComponentServlet</servlet-class>
    <init-param>
        <param-name>definitions-config</param-name>
        <param-value>/WEB-INF/tileDefinitions.xml</param-value>
    </init-param>
    ...
  </servlet>

3,配置struts-config.xml
<action path="/a" type="com.malani.struts.action.DoFirst">
        <forward name="success" path="aDef"/>
    </action>

调用一个重定向的servlet DoFirst访问aDef,即tileDefinitions.xml 中配置的具体模板。


 

本文地址:http://com.8s8s.com/it/it16238.htm