您的位置:首页 > 其它

Sitemesh 自定义decorators.xml 文件路径

2013-05-11 10:34 363 查看
实现思路: 通过覆盖默认的sitemesh.xml来实现

1. 打开sitemesh的jar文件, 在com.opensymphony.module.sitemesh.factory目录里找到sitemesh-default.xml,

将其复制到项目的任意目录(如/commons/sitemsh/目录), 并将其改名为sitemesh.xml;

2. 在web.xml文件里添加一个容器参数sitemesh.configfile,值为sitemesh.xml的项目路径. 具体如下:

<context-param>
<param-name>sitemesh.configfile</param-name>
<param-value>/commons/sitemesh/sitemesh.xml</param-value>
</context-param>

3.修改sitemesh.xml中属性为decorators-file的value值,根据decorators.xml 文件所在的项目路径来修改(如decorators.xml 位于/commons/sitemesh目录),其余配置保持不变.,具体如下:

<sitemesh>
<property name="decorators-file" value="/commons/sitemesh/decorators.xml"/>
<excludes file="${decorators-file}"/>

<page-parsers>
<parser content-type="text/html" class="com.opensymphony.module.sitemesh.parser.HTMLPageParser"/>
</page-parsers>

4. 通过以上设置也就完成了自定义decorators.xml 文件路径 的功能.

更多信息请参考sitemesh 源码中的 DefaultFactory.java 文件.

帮助别人,提升自己.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: