用sitemesh作站点布局

sitemesh是J2EE应用框架之一,用下面简单几个步骤就可以实现最简单的功能。

sitemesh的下载地址:opensymphony.sourceforge.net

1、copy sitemesh-2.3.jar 到 /WebRoot/WEB-INF/lib
2、copy sitemesh-decorator.tld、sitemesh-page.tld 到 /WebRoot/WEB-INF/
3、修改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>
  </filter-mapping>
  <jsp-config>
   <taglib>
   <taglib-uri>sitemesh-page</taglib-uri>
   <taglib-location>/WEB-INF/sitemesh-page.tld</taglib-location>
   </taglib>
   <taglib>
   <taglib-uri>sitemesh-decorator</taglib-uri>
   <taglib-location>/WEB-INF/sitemesh-decorator.tld</taglib-location>
   </taglib>
  </jsp-config>
4、在/WebRoot/WEB-INF/下添加decorators.xml
    <?xml version="1.0" encoding="UTF-8" ?>
      <decorators defaultdir="/decorators">
        <decorator name="frame" page="frame.jsp">
<pattern>/*</pattern>
</decorator>
      </decorators>
5、在/WebRoot/下建目录decorators,并在decorators目录中建frame.jsp
    <%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator"%>
    <html>
<head>
<title>Demo - <decorator:title default="Welcome!" />
</title>
<decorator:head />
</head>

<body>
<div align="center">
<hr>
This is sitemesh Test!
<hr>
<decorator:body />
<hr>
2008 copyright jllb@163.com
</div>
</body>
    </html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值