使用sitemesh的基本配置
1、官网 : http://www.opensymphony.com/sitemesh/
下载链接:http://www.opensymphony.com/sitemesh/download.action
官网说法:
SiteMesh - SiteMesh Installation and Configuration
Once SiteMesh has been downloaded (or built), configuration is simple.
* Setup a web-app as usual (or skip all this by using the pre-configured sitemesh-blank.war).
* Copy sitemesh-2.4.1.jar into [web-app]/WEB-INF/lib.
* Create the file [web-app]/WEB-INF/decorators.xml that contains the following:
<decorators>
</decorators>
* (Optional) Create the file [web-app]/WEB-INF/sitemesh.xml that contains the following:
<sitemesh>
<property name="decorators-file" value="/WEB-INF/decorators.xml" />
<excludes file="${decorators-file}" />
<page-parsers>
<parser content-type="text/html"
class="com.opensymphony.module.sitemesh.parser.HTMLPageParser" />
<parser content-type="text/html;charset=ISO-8859-1"
class="com.opensymphony.module.sitemesh.parser.HTMLPageParser" />
</page-parsers>
<decorator-mappers>
<mapper class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper">
<param name="config" value="${decorators-file}" />
</mapper>
</decorator-mappers>
</sitemesh>
* Add the following to [web-app]/WEB-INF/web.xml within the <web-app> tag:
<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>
从官网的介绍可知,使用sitemesh要进行3个步骤的配置:
1、导入架包:sitemesh-2.4.1.jar
2、配置decorators.xml(必须有),sitemesh.xml(可选,但最好配置)
3、web.xml中注册sitemesh过滤器
下面将上面所说的3步的详细配置过程介绍如下:
第一步:导入架包。
进入官网后可以看到如下结构:(选择JAR链接下载的是需要的架包)
Version 2.4.1
下载得到了sitemesh-2.4.1.jar架包后,在你项目中引入。第一步就搞定了。
第二步:配置相关的XML文件。
在你项目的/WebRoot/WEB-INF/目录下新建一个decorators.xml和一个sitemesh.xml的空的XML文件。
在decorators.xml中这样配置:
<?xml version="1.0" encoding="UTF-8"?>
<!--* defaultdir: 包含装饰器页面的目录
* page : 页面文件名
* name : 别名
* role : 角色,用于安全
* webapp : 可以另外指定此文件存放目录
* Patterns : 匹配的路径,可以用*,那些被访问的页面需要被装饰。
-->
<decorators defaultdir="/decorators">
<!-- 用来定义不需要过滤的页面 -->
<excludes>
<!-- 过滤掉load进的页面 -->
<pattern>/page/lesquare/specialties/special_java.jsp</pattern>
<pattern>/page/lesquare/specialties/special_.net.jsp</pattern>
</excludes>
<!-- 用来定义装饰器要过滤的页面 -->
<decorator name="siteMesh" page="siteMesh.jsp">
<pattern >/*</pattern>
</decorator>
</decorators>
在sitemesh.xml可以这样配置:
<?xml version="1.0" encoding="UTF-8"?>
<sitemesh>
<property name="decorators-file" value="/WEB-INF/decorators.xml" />
<excludes file="${decorators-file}" />
<page-parsers>
<parser content-type="text/html"
class="com.opensymphony.module.sitemesh.parser.HTMLPageParser" />
<parser content-type="text/html;charset=UTF-8"
class="com.opensymphony.module.sitemesh.parser.HTMLPageParser" />
</page-parsers>
<decorator-mappers>
<mapper class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper">
<param name="config" value="${decorators-file}" />
</mapper>
</decorator-mappers>
</sitemesh>
第三步:在web.xml中注册sitemesh过滤器
<!-- sitemesh过滤器 -->
<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>
经过上面的配置你的sitemesh就可以工作了,其实就这么简单。
分享到:
相关推荐
Sitemesh 3 的使用及配置
siteMesh demo siteMesh使用文档
概述 Struts 2.0提供一个Sitemesh插件... 缺省情况下,sitemesh假定装饰器文件保存在应用上下文根路径下的decorators目录下,如果采用如上配置,装饰器文件应该是ftl格式,如果需要使用其他格式,需要更改过滤器配置。
sitemesh 装饰 母版
web布局框架 SiteMesh教程及SiteMesh官方文档翻译
siteMesh使用示例:登录、注册页面
这个是sitemesh在项目中的应用,还有相关的jar包和资料,最重要的还有例子。
公司的OA流項目視圖層都是採用sitemesh技術,感覺還可以,裝潢頁面,技術不是很複雜,頁面結構清晰,佈局明朗,很好的佈局框架。
sitemesh 使用例子。 <?xml version="1.0" encoding="utf-8"?> <decorators defaultdir="/decorators"> <!-- 此处用来定义不需要过滤的页面 --> <excludes> </excludes> <!-- 用来定义装饰器要过滤的...
sitemesh.jar包 sitemesh.jar 包sitemesh.jar 包sitemesh.jar包
sitemesh3的一个demo,附带配置说明
SiteMesh是一个网页布局和装饰框架以及Web应用程序集成框架,可帮助创建由页面组成的网站,这些页面需要一致的...SiteMesh可以在基于Java的Web应用程序中使用,也可以作为脱机作业应用于内容。 SiteMesh是可扩展的。
本书使用版本:2.1 官方网站:http://boss.bekk.no/boss/middlegen/ 下载页面:http://sourceforge.net/project/showfiles.php?group_id=36044 下载地址:...
sitemesh 装饰页面技术.
sitemesh入门demo。博客 Sitemesh入门和使用笔记 对应源码
用于在SSH2工程中使用sitemesh-2.4.jar 包;
sitemesh-2.2.1.jar
sitemesh3包括lib,api,demo,配置说明,希望大家喜欢
很简单的sitemesh入门教程,希望对大家有所帮助
sitemesh3-demo 配置说明参见http://blog.csdn.net/thc1987/article/details/6913416