一、使用maven引包
<dependency>
<groupId>org.sitemesh</groupId>
<artifactId>sitemesh</artifactId>
<version>${org.sitemesh.version}</version>
</dependency>
二、项目结构,在WEB-INF中新建sitemesh3.xml和一个装饰页面
三、在web.xml中添加filter
<!-- sitemesh过滤器start -->
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>
org.sitemesh.config.ConfigurableSiteMeshFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/pages/*</url-pattern>
</filter-mapping>
<!-- sitemesh过滤器end -->
四、sitemesh3.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<sitemesh>
<!-- 指明页面,将被装饰 -->
<mapping path="/pages/system/*" decorator="/WEB-INF/views/decorators/main.jsp" />
<!-- 指明页面,将被排除,不被装饰 -->
<mapping path="/pages/system/login*" exclue="true" />
<mapping path="/pages/error/*" exclue="true" />
</sitemesh>
五、装饰页面中的标签使用
<!-- 从被装饰页面获取title标签内容-->
<title>后台管理系统 - <sitemesh:write property='title' /></title>
<!-- 从被装饰页面获取head标签内容 -->
<sitemesh:write property='head' />
<!-- 从被装饰页面获取body标签内容 -->
<sitemesh:write property='body' />
和sitemesh2不同,sitemesh3还有可以自定义标签,所以装饰页面就不用引入taglib了。