标签:sitemesh应用
在WEB-INF--lib下导入sitemesh的jar包
web.xml中添加如下代码
<!-- sitemesh --> <filter> <filter-name>sitemesh</filter-name> <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class> </filter> <filter-mapping> <filter-name>sitemesh</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
新建decorators.xml 表示该样式作用于哪些JSP页面
<?xml version="1.0" encoding="UTF-8"?> <decorators defaultdir="/decorators"> <decorator name="banner" page="banner.jsp"> <pattern>/jsp/*</pattern><!--jsp目录--> </decorator> </decorators>
公共样式就在webroot下的decorators文件下面
如banner.jsp
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %> <div id="templatemo_menu"> <ul> <li><a href="home.jsp" class="current">Home</a></li> <li><a href="showAll" class="current">Review</a></li> <li><a href="write.jsp" class="current">Write Review</a></li> <li><a href="list" class="current">Book</a></li> <li><a href="us.jsp" class="current">About Us</a></li> <li><a href="show.jsp" class="current">show bookq</a></li> </ul> </div> </div><!-- end of container --> <decorator:body /> <div id="templatemo_container"> <div id="templatemo_footer">
这样其他的JSP页面就可以运用公共样式了!
标签:sitemesh应用
原文地址:http://5666522.blog.51cto.com/5656522/1630584