我在Spring MVC应用程序中使用了四个过滤器,今天意识到过滤器的排序也很重要(在调试浪费了大量时间之后,参考Spring security tags in sitemesh decorator修复了装饰问题)。我仍然需要帮助找到这些过滤器的正确顺序,因为我还在学习Spring。请指教。
我的web.xml是:
http://java.sun.com/xml/ns/j2ee/web-app_3_1.xsd" 版本=" 3.1">
<display-name>Sample App</display-name> <description>Sample Application</description> <context-param> <description>locations of the Spring configuration files</description> <param-name>contextConfigLocation</param-name> <param-value> classpath:spring/application-service.xml, classpath:spring/application-servlet.xml, classpath:spring/application-dao.xml, classpath:spring/application-security.xml, classpath:spring/application-social.xml, classpath:spring/application-mailservice.xml, </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!--- Servlet that dispatches request to registered handlers (Controller implementations). --> <servlet> <servlet-name>application</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/application-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>application</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <filter> <filter-name>httpMethodFilter</filter-name> <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> </filter> <filter-mapping> <filter-name>httpMethodFilter</filter-name> <servlet-name>application</servlet-name> </filter-mapping> <!-- Enables Spring Security --> <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class> org.springframework.web.filter.DelegatingFilterProxy </filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>sitemesh</filter-name> <filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class> </filter> <filter-mapping> <filter-name>sitemesh</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>encoding-filter</filter-name> <filter-class> org.springframework.web.filter.CharacterEncodingFilter </filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encoding-filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>