sitemesh使用

1. SiteMesh的简介

 

        Sitemesh是由一个基于Web页面布局、装饰及与现存Web应用整合的框架。它能帮助我们再由大量页面工程的项目中创建一致的页面布局和外观,如一致的导航条、一致的banner、一致的版权等。

 

2. SiteMesh的工作原理

SiteMesh是基于Servlet的filter的,即过滤流。它是通过截取reponse,并进行装饰后再交付给客户。

其中涉及到两个名词: 装饰页面(decorator page)和 “被装饰页面(Content page)" , 即 SiteMesh通过对Content Page的装饰,最终得到页面布局和外观一直的页面,

并返回给客户

 

 

3. SiteMesh的配置

3.1 web.xml的配置

Sitemesh2

    <filter>

       <filter-name>sitemesh2</filter-name>

    <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>

    </filter>

    <filter-mapping>

       <filter-name>sitemesh2</filter-name>

       <url-pattern>/*</url-pattern>

    </filter-mapping>

 

 

Sitemesh3

 

    <filter>

       <filter-name>sitemesh3</filter-name>

    <filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class>

    </filter>

    <filter-mapping>

       <filter-name>sitemesh3</filter-name>

       <url-pattern>/*</url-pattern>

    </filter-mapping>

 

Sitemesh2:

3.2 建立decorators.xml

在/WEB-INF下创建decorators.xml文件,siteMesh通过该文件来获知"装饰页面"和"被装饰页面"的映射

<decorators defaultdir="/decorators">

 

<excludes>

<pattern>/page/menu.jsp</pattern>

</excludes>

 

    <decorator name="basic-theme"page="decorator.jsp">

        <pattern>/*</pattern>

    </decorator>

</decorators>

 

SiteMesh3

3.3  建立配置文件(sitemesh3.xml)

在/WEB-INF下创建sitemesh3.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<sitemesh>

 <mapping path="/page/menu.jsp exclude="true"/>
  <mapping path="/*" decorator="/decorators/decorator.jsp"/>

</sitemesh> 

 

3.4 建立装饰页(decorator.jsp)

 

4 sitemesh常用标签

Sitemesh2 :

<decorator:head />

插入原始页面(被包装页面)的head标签中的内容

<decorator:title [default="..." ] />

<decorator:body />

<decorator:getPropertyproperty="..." [ default="..." ] [writeEntireProperty="..." ]/>

 

 

 

Sitemesh3:

<sitemesh:write property=''/>

Head ,body title

 <�|>/X]P�[rong>

 

 

Sitemesh3:

<sitemesh:write property=''/>

Head ,body title

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sust2012

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值