sitemesh装饰页面

步骤:

1,引入sitemesh的jar包

2,引入struts2对sitemesh的支持包:struts2-sitemesh-plugin-x.x.x.jar

3,修改web.xml文件,添加ActionContextCleanup和sitemesh过滤器

<filter>
	<filter-name>struts-cleanup</filter-name>
	<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter>
	<filter-name>sitemesh</filter-name>
	<filter-class>org.apache.struts2.sitemesh.FreeMarkerPageFilter</filter-class>
</filter>


<filter-mapping>
	<filter-name>struts-cleanup</filter-name>
	<url-pattern>/*</url-pattern>
</filter-mapping>
	
<filter-mapping>
	<filter-name>sitemesh</filter-name>
	<url-pattern>/*</url-pattern>
</filter-mapping>

4,提供decorators.xml配置文件,在这个配置文件中定义装饰器的路径,需要放到WEB-INF目录下

5,创建装饰器

6,使用装饰器

      -->在头部添加一条语句:<meta name="decorator" content="navigation">

你可能感兴趣的:(apache,Web,xml,struts)