struts2 maven整合tiles3

最新项目发现使用tiles能够很好的将多个页面组合起来,以下就是配置信息,使用tiles3

1、首先配置maven pom.xml加入例如以下:

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles3-plugin</artifactId>
<version>2.3.16.3</version>
</dependency>

2、在WEB-INF文件夹下加入tiles.xml

 <tiles-definitions>
<definition name="pets.base" template="/entrance/base.jsp">
<put-attribute name="header" value="/entrance/header.jsp"></put-attribute>
<put-attribute name="body" value="/aa.jsp"></put-attribute>
<put-attribute name="footer" value="/bb.jsp"></put-attribute>
</definition>
</tiles-definitions>

 3、配置成后,在模板页面【/entrance/base.jsp】中须要加入标签

<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>

使用时<tiles:insertAttribute name="header"></tiles:insertAttribute> name就是步骤2中的put-attribute节点的name

4、须要在web.xml中加入监听

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




原文地址:https://www.cnblogs.com/zsychanpin/p/6785570.html