SiteMesh介绍
SiteMesh是一个网页布局和修饰的框架,利用它可以将网页的内容和页面结构分离,以达到页面结构共享的目的。
下载和安装SiteMesh
官方下载地址:http://www.opensymphony.com/sitemesh/download.action
配置过滤器
在web.xml中
<filter><filter-name>sitemesh</filter-name><filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class></filter><filter-mapping><filter-name>sitemesh</filter-name><url-pattern>/*</url-pattern></filter-mapping>
decorators.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/WEB-INF/layouts/"><!-- 不走布局的url --><excludes><pattern>/v2/api-docs</pattern><pattern>/swagger/**</pattern><pattern>/static/*</pattern><pattern>/kindeditor/*</pattern><pattern>/*/ajax/*</pattern><pattern>/admin</pattern></excludes><!-- 默认布局 --><decorator name="default" page="default.jsp"><pattern>/*</pattern></decorator><!-- 后台管理布局 --><decorator name="admindefault" page="admin/default.jsp"><pattern>/admin/*</pattern><pattern>/admin/**/*</pattern></decorator><!-- edu前端布局 --><decorator name="webdefault" page="web/default.jsp"><pattern>/front/*/*</pattern><pattern>/front/*</pattern></decorator><!--uc布局 --><decorator name="ucdefault" page="web/uc/default_uc.jsp"><pattern>/uc/*</pattern><pattern>/uc/**/*</pattern></decorator>
</decorators>