jackyrong

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
    asp.net 中有master-page母板页,而java里也有类似的好东西,那就是sitemesh了,做同样东西的工具.
下面是简单使用步骤
1 把下载好的sitemesh.jar放好
2 先做一个母版页,比如
    <%@ page contentType="text/html; charset=GBK"%>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator"%>
<html>
 <head>
  <title><decorator:title default="第一个装饰器页面"/></title>
  <decorator:head/>
 </head>
 <body>
  SiteMesh快速入门<hr>
  <decorator:body />
  <hr>
  <div style="font:9pt" align="center">SiteMesh快速入门 by Yeeku.H.Lee</div>
 </body>
</html>

 把这个文件放在decorator目录下,起个名,比如main.jsp
那么以后<decorator:boday>,表示其他具体页面的东西就放在这里了,<decorator:title>也是一样的道理.
然后再在web-inf目录下设置decorator.xml,
<?xml version="1.0" encoding="GBK"?>
<!-- defaultdir指定装饰器文件所在的路径 -->
<decorators defaultdir="/decorators">
 <!-- 指定main装饰器,该装饰器使用main.jsp页面 -->
    <decorator name="main" page="main.jsp">
  <!-- 使用main装饰器装饰所有的JSP页面 -->
        <pattern>*</pattern>
    </decorator>
</decorators>
 3 最重要的是web.xml里,必须按如下顺序配置flter:
   <filter>
        <filter-name> struts-cleanup </filter-name>
        <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
    </filter>
   
     <filter>
     <filter-name>sitemesh</filter-name>
     <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
    </filter>
   
     <filter>
     <filter-name>struts</filter-name>
     <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
posted on 2008-07-11 17:49  jackyrong的世界  阅读(464)  评论(0编辑  收藏  举报