Apache Tiles integration with JSP and Servlet webapp

六月ゝ 毕业季﹏ 提交于 2019-12-13 04:52:02

问题


I have successfully integrated Apache Tiles with my webstore which is built on pure JSP and Servlet technology (Tomcat 8). I am using Apache Tiles only and only for page templating, nothing else and my maven pom includes the dependency as follows:

pom.xml

<dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-extras</artifactId>
    <version>3.0.5</version>
</dependency>

I have the feeling that tiles-extras pulls in everything that I may not even be using. My question is which specific jar should I include for templating? I am using a template.jsp which acts as the base JSP template page which looks as follows:

template.jsp

  <body>
        <table class="noborder">
            <tr>
                <td>
                    <tiles:insertAttribute name="header"/>
                    <tiles:insertAttribute name="body"/><br/><br/>
                    <tiles:insertAttribute name="footer"/>
                </td>
            </tr>
        </table>
    </body>

WEB-INF/tiles.xml

<tiles-definitions>
    <definition name="homePage" template="/jsp/template.jsp">
        <put-attribute name="header" value="/jsp/header/header.jsp" />
        <put-attribute name="body" value="/jsp/content/home/home.jsp" />
        <put-attribute name="footer" value="/jsp/footer/footer.jsp" />
    </definition>

web.xml

<listener>
        <listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>Tiles Dispatch Servlet</servlet-name>
        <servlet-class>org.apache.tiles.web.util.TilesDispatchServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Tiles Dispatch Servlet</servlet-name>
        <url-pattern>*.tiles</url-pattern>
    </servlet-mapping>

回答1:


If you not use the tiles-extra tags add only tiles-jsp



来源:https://stackoverflow.com/questions/29808419/apache-tiles-integration-with-jsp-and-servlet-webapp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!