Struts2.2.1配置sitemesh和freemarker
导入包:
struts2-core-2.2.1.jar
struts2-sitemesh-plugin-2.2.1.jar
sitemesh-2.4.2.jar
web.xml的配置
过滤器配置: <filter> <filter-name>struts-prepare</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class> </filter> <filter> <filter-name>sitemesh</filter-name> <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class> </filter> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts-prepare</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>sitemesh</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 监听器配置: <servlet> <servlet-name>sitemesh-freemarker</servlet-name> <servlet-class>org.apache.struts2.sitemesh.FreemarkerDecoratorServlet</servlet-class> <init-param> <param-name>default_encoding</param-name> <param-value>UTF-8</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>sitemesh-freemarker</servlet-name> <url-pattern>*.ftl</url-pattern> </servlet-mapping> <listener> <listener-class>org.apache.struts2.dispatcher.ng.listener.StrutsListener</listener-class> </listener>
sitemesh.xml
<sitemesh> <property name="decorators-file" value="/WEB-INF/decorators.xml"/> <excludes file="${decorators-file}"/> <page-parsers> <parser default="true" class="com.opensymphony.module.sitemesh.parser.HTMLPageParser"/> <parser content-type="text/html" 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>
decorators.xml
<decorators defaultdir="/decorators"> <excludes> <pattern>/index.html</pattern> </excludes> <decorator name="default" page="default.ftl"> <pattern>/*</pattern> </decorator> </decorators>
相关推荐
hgzhang 2020-05-06
白净垃圾桶 2020-05-04
playis 2020-04-18
郭大路路 2020-04-16
lenchio 2020-04-08
yixiaoqi00 2020-04-08
melonjj 2020-01-05
mmywcoco 2019-12-28
wangruiling 2014-06-13
yaoyao0 2014-06-01
YangHuiLiang 2014-05-20
方志朋 2019-12-22
xcguoyu 2014-01-18
方志朋 2015-04-30
殷龙飞 2014-06-24
zmysna 2016-12-16
89264255 2011-04-23
wuddny的blog 2014-12-04