读书人

运用sitemesh的基本配置

发布时间: 2012-10-24 14:15:58 作者: rapoo

使用sitemesh的基本配置

使用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"

?? ? ? ? ? ? ? ? ?/>

?? ? ? ? ? ? ?<parser content-type="text/html;charset=ISO-8859-1"

?? ? ? ? ? ? ? ? ?/>

?? ? ? ? ?</page-parsers>

?

?? ? ? ? ?<decorator-mappers>

?? ? ? ? ? ? ?<mapper 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

读书人网 >Web前端

热点推荐