<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> <taglib> <taglib-uri>sitemesh-decorator</taglib-uri> <taglib-location>/WEB-INF/sitemesh-decorator.tld</taglib-location> </taglib> <taglib> <taglib-uri>sitemesh-page</taglib-uri> <taglib-location>/WEB-INF/sitemesh-page.tld</taglib-location> </taglib>
<decorators defaultdir="/_decorators"> <decorator name="main" page="main.jsp"> <pattern>*</pattern> </decorator> </decorators>
<%@ page contentType="text/html; charset=GBK"%> <%@ taglib uri="sitemesh-decorator" prefix="decorator" %> <html> <head> <title><decorator:title default="装饰器页面..." /></title> <decorator:head /> </head> <body> sitemesh的例子<hr> <decorator:body /> <hr>chen56@msn.com </body> </html>
<%@ page contentType="text/html; charset=GBK"%> <html> <head> <title>Agent Test</title> </head> <body> <p>本页只有一句,就是本句.</p> </body> </html>
最后访问index.jsp,将生成如下页面:
而且,所有的页面也会如同index.jsp一样,被sitemesh的filter使用装饰模式修改成如上图般模样,却不用再使用include标签。
posted on 2009-10-26 12:50 mingruofei 阅读(63) 评论(0) 编辑 收藏