struts2_大纲10_sitemesh

OS(OpenSymphony)的SiteMesh是一个用来在JSP中实现页面布局和装饰
(layout and decoration)的框架组件,能够帮助网站开发人员较容
易实现页面中动态内容和静态装饰外观的分离


SiteMesh使用方式:
①导包:
sitemesh-2.4.2.jar
struts2-sitemesh-plugin-2.2.3.jar
②web.xml中配置过滤器
org.apache.struts2.dispatcher.ActionContextCleanUp
com.opensymphony.sitemesh.webapp.SiteMeshFilter
org.apache.struts2.dispatcher.FilterDispatcher
③在WEB-INF中建立装饰器配置文件decorators.xml
<!-- defaultdir指定模板存放的文件夹 -->
<decorators defaultdir="/template">
<!-- 表示排除装饰的页面-->
<excludes>
<pattern>/login.jsp</pattern>
</excludes>

<!-- 指定具体模板 -->
<decorator name="m" page="template.jsp">
<!-- 设置需要被装饰的页面 -->
<pattern>/*</pattern>
</decorator>
<decorator name="head" page="head.jsp"></decorator>
<decorator name="menu" page="menu.jsp"></decorator>
<decorator name="foot" page="foot.jsp"></decorator>
</decorators>
④基本模板页template.jsp中引入标签
<%@ taglib  prefix="sitemesh-decorator" uri="http://www.opensymphony.com/sitemesh/decorator"%>
<%@ taglib  prefix="sitemesh-page" uri="http://www.opensymphony.com/sitemesh/page" %>
模板页中基础配置
<head>
  
<title>
<sitemesh-decorator:title default="Mysterious page..." /> 
</title>
  
<!-- 把被装饰的页面的头信息取过来 -->
<sitemesh-decorator:head />


<body>
  
<sitemesh-page:applyDecorator name="header" /> 


<!-- 把被装饰页面的body信息提取过来显示 -->
   
<sitemesh-decorator:body />
<sitemesh-page:applyDecorator name="fooder" /> 


</body>

</html>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值