2015-04-07 2 views
0

Я создаю веб-проект Java с Spring, Maven и Apache Tomcat 7. В этом проекте у меня есть web.xml так:Как заказать фильтры с Apache Tomcat 7

<display-name>web</display-name> 

<welcome-file-list> 
    <welcome-file>index.jsp</welcome-file> 
</welcome-file-list> 

<!-- Servlet de Spring. Definimos el Servlet que recibirá todas las peticiones que 
    se realizen a la página --> 

<servlet> 
    <servlet-name>spring</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    <load-on-startup>1</load-on-startup> 
</servlet> 
<servlet-mapping> 
    <servlet-name>spring</servlet-name> 
    <url-pattern>/</url-pattern> 
</servlet-mapping> 
<!-- <context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>/WEB-INF/spring-servlet.xml</param-value> 
</context-param> --> 
<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 

<absolute-ordering> 
    <name>encodingFilter</name> 
    <name>cors</name> 
    <name>springSecurityFilterChain</name> 
    <name>FileUploadFilter</name> 
</absolute-ordering> 

<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>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> 
    <filter-name>cors</filter-name> 
    <filter-class>filters.SimpleCorsFilter</filter-class> 
    <init-param> 
     <param-name>encoding</param-name> 
     <param-value>UTF-8</param-value> 
    </init-param> 
</filter> 

<filter-mapping> 
    <filter-name>cors</filter-name> 
    <url-pattern>/api/*</url-pattern> 
</filter-mapping> 

<error-page> 
    <location>/error</location> 
</error-page> 
<error-page> 
    <error-code>404</error-code> 
    <location>/error</location> 
</error-page> 
<error-page> 
    <error-code>500</error-code> 
    <location>/error</location> 
</error-page> 
<error-page> 
    <exception-type>java.lang.Throwable</exception-type> 
    <location>/error</location> 
</error-page> 

Когда я начинаю Tomcat появляется следующие сообщения на консоли:

org.apache.catalina.deploy.WebXml orderWebFragments 
Used a wrong fragment name encodingFilter at web.xml absolute-ordering tag! 
org.apache.catalina.deploy.WebXml orderWebFragments 
Used a wrong fragment name cors at web.xml absolute-ordering tag! 
org.apache.catalina.deploy.WebXml orderWebFragments 
Used a wrong fragment name springSecurityFilterChain at web.xml absolute-ordering tag! 

Я пробовал то же самое с Apache Tomcat 6 и у меня не было никаких проблем. Любая идея?

ответ

0

Не похоже, что вы можете определить порядок для сервлет-фильтров . Смотрите следующие сообщения здесь на SO

  1. <absolute-ordering> is not working in tomcat 7
  2. Servlet filters' order of execution
  3. How to define servlet filter order of execution using annotations in WAR
+0

Большое вам спасибо за ваш ответ. Я проверил ссылки, которые у вас есть, и я думаю, что я не могу реализовать решения fisrt и последней ссылки, потому что я не могу изменить веб-фрагменты фильтров Spring для создания заказа. Я попробую второй вариант – battu

Смежные вопросы