步骤:
1、下载sitemesh-2.4.1.jar。
2、把jar复制到webapp应用lib下,创建decorators.xml文件,并修改web.xml。
webapp
├─META-INF
└─WEB-INF
├─ftl/ (freemaker模板文件)
├─lib/sitemesh-2.4.1.jar
├─decorators.xml
└─web.xml
3、decorators.xml内容如下:
<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>
4、修改web.xml 文件如下:
<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>
That's it! Your web-app is now setup to use SiteMesh, you can now start building decorators.