Apache Tiles与JSP和Servlet WebApp的集成 [英] Apache Tiles integration with JSP and Servlet webapp

查看:115
本文介绍了Apache Tiles与JSP和Servlet WebApp的集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功地将Apache Tiles与我的基于纯JSP和Servlet技术(Tomcat 8)构建的Webstore集成在一起.我仅使用Apache Tiles,并且仅用于页面模板,其他都没有,而且我的maven pom包括以下依赖项:

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>

我感觉到tiles-extras将所有我可能没有使用的东西都拉进去了.我的问题是我应该包括哪个特定的模板模板?我正在使用template.jsp作为基本JSP模板页面,该页面如下所示:

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>

推荐答案

如果不使用tiles-extra标签,则仅添加tiles-jsp

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

这篇关于Apache Tiles与JSP和Servlet WebApp的集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆