sitemesh配置
来源:互联网 发布:童虎和撒加 知乎 编辑:程序博客网 时间:2024/04/30 03:55
sitemesh是一个装饰页面的插件。它会拦截页面的html代码里的title,header,body。这样它就可以将一些公共的信息插入进去。起到了类似于include的作用。但它不会侵入代码。
官方网站:http://www.opensymphony.com/sitemesh/
SiteMesh - 安装和配置
siteMesh的配置相当简单.
- 拷贝
sitemesh-2.4.1.jar
到[web-app]/WEB-INF/lib
. - 新建文件到
[web-app]/WEB-INF/decorators.xml
,它包含如下内容:<decorators>
</decorators> - 添加如下信息到
[web-app]/WEB-INF/web.xml
的<web-app>
标签中:<filter>
<filter-name>sitemesh
</filter-name>
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter
</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.xml
<!-- 定义装饰器页面的文件路径/decorators,它会去/decorators下面找装饰器面页-->
<decorators defaultdir="/decorators">
<!-- 定义一个装饰器,pattern里面的文件都会被装饰器处理 -->
<decorator name="main" page="main.jsp">
<pattern>/buyer/*.jsp</pattern>
<pattern>/remit/*.action</pattern>
</decorator>
<!-- 定义一些不需要装饰器处理的页面或aciton-->
<excludes>
<pattern>/buyer/index.jsp</pattern>
<pattern>/batchQueryAccountDetail.action</pattern>
</excludes>
</decorators>
建立一个装饰器面页/decorators/main.jsp
<%@ 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>
建立一个的被装饰页面 /index.jsp(内容页面)
<%@ page contentType="text/html; charset=GBK"%>
<html>
<head>
<title>Agent Test</title>
</head>
<body>
<p>本页只有一句,就是本句.</p>
</body>
</html>
结果页面:
<html>
<head>
<title>
Agent Test
</title>
</head>
<body onclick="sfdsf">
sitemesh的例子<hr>
<p>本页只有一句,就是本句.</p>
<hr>chen56@msn.com
</body>
</html>
- sitemesh配置
- struts2之整合sitemesh(sitemesh配置)
- sitemesh配置解析
- sitemesh 配置手稿
- SiteMesh配置与使用
- Struts2 集成 sitemesh配置
- sitemesh、springmvc装饰配置
- sitemesh配置解析
- Sitemesh 3 配置
- SiteMesh在项目中的配置
- sitemesh原理与配置应用
- SSH配置(四)-sitemesh-velocity
- sitemesh原理与配置应用
- Sitemesh的配置与使用
- sitemesh
- SiteMesh
- Sitemesh
- Sitemesh
- 测18日2点墨西哥战法国,胜败如何?
- 加和不加的区别
- c++ explicit 关键字解析
- Hibernate过滤器
- S60平台:Avkon UI 资源-设置列表--S60 Platform: Avkon UI Resources- Setting Lists翻译连载二
- sitemesh配置
- poj 1191 DP by:me
- poj 1191 DP by:other
- 基于.NET Framework 4.0的解决方案部署
- sitemesh的标签
- 是时候抛弃流氓QQ了!
- 用New-WebServiceProxy查天气预报
- 中国佛学66句震撼世界的禅语
- RakNet的配置