SiteMesh是一个网页布局和修饰的框架,利用它可以将网页的内容和页面结构分离,以达到页面结构共享的目的
jar包 sitemesh-2.4.2.jar
web.xml配置
<filter>
<filter-name>sitemeshFilter</filter-name>
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemeshFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
web.xml同级 目录下 decorators.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/jsp"> //装饰文件的目录
<excludes>
</excludes> //不需要装饰
<decorator name="default" page="default.jsp"> //装饰文件名
<pattern>/*</pattern><span style="white-space:pre"> </span>//需要装饰
</decorator><span style="white-space:pre"> </span>
</decorators>
default.jsp
<head>
<title>默认title<sitemesh:title/></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script src="<span style="color:#ff0000;">${pageContext.request.contextPath}/js/jquery-1.6.1.js</span>" type="text/javascript"></script> //不要写相对路径
<sitemesh:head />
</head>
<body>
<div>
hhhhead
<div>
<sitemesh:body />
</div>
fffoooott
</div>
</body>
</html>