`

webwork与sitemesh在web.xml里面的配置问题

阅读更多
今天在工程里用sitemesh的时候发现有的页面怎么也不会被装潢。找了一下午终于找出原因来了 原来是webwork与sitemesh在web.xml的配置顺序问题。正确的顺序应该是先经过sitemesh的过滤器然后再经过 webwork的过滤器。
我正确的配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 
	xmlns="http://java.sun.com/xml/ns/j2ee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
	http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	
	<filter>
  <filter-name>sitemesh</filter-name>
		<filter-class>
			com.opensymphony.module.sitemesh.filter.PageFilter
		</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>sitemesh</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	
  <taglib>
    <taglib-uri>sitemesh-page</taglib-uri>
    <taglib-location>/WEB-INF/sitemesh-page.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>sitemesh-decorator</taglib-uri>
    <taglib-location>/WEB-INF/sitemesh-decorator.tld</taglib-location>
  </taglib>
	<filter>
		<filter-name>webwork</filter-name>
		<filter-class>
			com.opensymphony.webwork.dispatcher.FilterDispatcher
		</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>webwork</filter-name>
		<url-pattern>*.action</url-pattern>
		<dispatcher>REQUEST</dispatcher>
		<dispatcher>FORWARD</dispatcher>
	</filter-mapping>
	
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

Global site tag (gtag.js) - Google Analytics