gpt4 book ai didi

java - 如何使用 Apache Tomcat 7 订购过滤器

转载 作者:行者123 更新时间:2023-11-28 22:29:01 25 4
gpt4 key购买 nike

我正在使用 Spring、maven 和 Apache Tomcat 7 创建一个 Java web 项目。在这个项目中,我有一个像这样的 web.xml:

<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 上尝试过相同的操作,但没有遇到任何问题。有什么想法吗?

最佳答案

关于java - 如何使用 Apache Tomcat 7 订购过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29485676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com