看看STRUTS入门到精通!!这本书!!!!!看了后你就明白了!!!其实tiles很简单!!

解决方案 »

  1.   

    去这里
    http://www.lifl.fr/~dumoulin/tiles/tiles.zip
    或这里
    http://www.geocities.com/cedricdumoulin/tiles/tiles.zip
    下载tiles
    里面包含一个空的包以及怎么跟struts1.0或struts1.1结合配置的.war文件,挺简单的,我也刚用这个,已经配好了
      

  2.   

    <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        
        <!-- module configurations -->
        
        <init-param>
          <param-name>config/admin</param-name>
          <param-value>/WEB-INF/admin/struts-config.xml</param-value>
        </init-param>
        
        <init-param>
          <param-name>config/userpicture</param-name>
          <param-value>/WEB-INF/userpicture/struts-config.xml</param-value>
        </init-param>
        
        <init-param>
          <param-name>debug</param-name>
          <param-value>2</param-value>
        </init-param>
        <init-param>
          <param-name>detail</param-name>
          <param-value>2</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
      </servlet>
      

  3.   

    如果你用的是 eclipse+myeclipse可以直接在“新建”里建立多个module,
    新建/other/myeclipse/web-struts/struts1.1/struts1.1 module,就会出现多个文件了。
    配置完后的web.xml文件如 insiderys(松) 所示。
      

  4.   

    多个config.xml对多个tiles的情况我已经配置成功了,只列出了需要注意的地方,请看-------------------------------------------------------------------------------
    web.xml
    =========================
     <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
    <init-param>
          <param-name>config/teach</param-name>
          <param-value>/WEB-INF/struts-teach.xml</param-value>
        </init-param>
        <init-param>
          <param-name>debug</param-name>
          <param-value>0</param-value>
        </init-param>
        <init-param>
          <param-name>application</param-name>
          <param-value>ApplicationResources</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
      </servlet>-------------------------------------------------------------------------
    struts-config.xml
    ===============================
    <!-- comment following if struts1.0.x -->
      <plug-in className="org.apache.struts.tiles.TilesPlugin" >
        <set-property property="definitions-config" 
                     value="/WEB-INF/definitions.xml" />
    <set-property property="moduleAware" value="true" />
        <set-property property="definitions-parser-validate" value="true" />
      </plug-in>
      <!-- end comment if struts1.0.x -->
    --------------------------------------------------------------------------
    struts-teach.xml
    ================================
     <!-- comment following if struts1.0.x -->
      <plug-in className="org.apache.struts.tiles.TilesPlugin" >
        <set-property property="definitions-config" 
                     value="/WEB-INF/teach-def.xml" />
    <set-property property="moduleAware" value="true" />
        <set-property property="definitions-parser-validate" value="true" />
      </plug-in>
      <!-- end comment if struts1.0.x -->
    然后就是tiles中的配置了,如definitions.xml
    ====================<?xml version="1.0" encoding="gb2312"?> <!DOCTYPE tiles-definitions PUBLIC
           "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
           "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
    <tiles-definitions>
    <definition name="baseDef" path="/main/layout.jsp">
    <put name="header" value="/main/header.jsp"/>
    <put name="footer" value="/main/footer.jsp"/>
    <put name="body" value=""/>
    </definition>
    <definition name="this.first" extends="baseDef">
    <put name="title" value="测试页面一(first.jsp),方法一"/>
    <put name="body" value="/main/first.jsp"/>
    </definition>
    <definition name="this.bdef" extends="baseDef">
    <put name="title" value="测试页面二(b.jsp),方法二"/>
    <put name="body" value="/main/b.jsp"/>
    </definition></tiles-definitions>另外一个:teach-def.xml
    ==========================
    <?xml version="1.0" encoding="gb2312"?> <!DOCTYPE tiles-definitions PUBLIC
           "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
           "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
    <tiles-definitions>
    <definition name="mainlayout" path="/main/layout.jsp">
    <put name="header" value="/main/header.jsp"/>
    <put name="footer" value="/main/footer.jsp"/>
    <put name="body" value=""/>
    </definition>
    <definition name="this.first" extends="mainlayout">
    <put name="title" value="测试页面"/>
    <put name="body" value="/teach/first.jsp"/>
    </definition>
    <definition name="bdef" extends="mainlayout">
    <put name="title" value="测试页面二(b.jsp),方法二"/>
    <put name="body" value="/main/b.jsp"/>
    </definition></tiles-definitions>