http://www.opensymphony.com/sitemesh/index.html
sitemesh .jar
|
WEB-INF/lib
|
sitemesh -decorator.tld
|
WEB-INF
|
sitemesh -page.tld
|
WEB-INF
|
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> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping>
建立 WEB-INF/decorators.xml 描述各装饰器页面。
<decorators defaultdir="/decorators"> <excludes> <pattern>/docs/api/*</pattern> </excludes> <decorator name="main" page="main.jsp"> <pattern>/*</pattern> </decorator> </decorators>
<%@ taglib uri="sitemesh-decorator" prefix="decorator" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/web.css"></link> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/jmesa.css"></link> <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.2.2.pack.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.bgiframe.pack.js"></script> <script type="text/javascript" src="${pageContext.request.contextPath}/js/jmesa.js"></script> <title>JMesa</title> <decorator:head/> </head> <body> <div style="height:75px;background-repeat:repeat-x;background-image: url('${pageContext.request.contextPath}/images/header.png')"> <a href="${pageContext.request.contextPath}/index.jsp"> <img id="header" src="${pageContext.request.contextPath}/images/logo.png" alt="logo" /> </a> </div> <div id="content"> <decorator:body/> </div> </body> </html>