在TOME中启用CORS会在所有路由上导致404

在TOME中启用CORS会在所有路由上导致404,cors,apache-tomee,javax,Cors,Apache Tomee,Javax,我使用以下web.xml文件在我的TomEE web服务器中启用了CORS: <?xml version="1.0" encoding="ISO-8859-1"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this

我使用以下
web.xml
文件在我的TomEE web服务器中启用了CORS:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
       http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0" metadata-complete="true">

    <display-name>Spotitube</display-name>


    <filter>
        <filter-name>CorsFilter</filter-name>
        <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>CorsFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter>
        <filter-name>CorsFilter</filter-name>
        <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
        <init-param>
            <param-name>cors.allowed.origins</param-name>
            <param-value>*</param-value>
        </init-param>
        <init-param>
            <param-name>cors.allowed.methods</param-name>
            <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
        </init-param>
        <init-param>
            <param-name>cors.allowed.headers</param-name>
            <param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
        </init-param>
        <init-param>
            <param-name>cors.exposed.headers</param-name>
            <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
        </init-param>
        <init-param>
            <param-name>cors.support.credentials</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>cors.preflight.maxage</param-name>
            <param-value>10</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>CorsFilter</filter-name>
        <url-pattern>*</url-pattern>
    </filter-mapping>


</web-app>

斯波提图
克斯菲尔特
org.apache.catalina.filters.CorsFilter
克斯菲尔特
/*
克斯菲尔特
org.apache.catalina.filters.CorsFilter
科尔斯
*
cors.methods
获取、发布、头部、选项、放置
cors.allowed.headers
内容类型、X-Requested-With、accept、Origin、访问控制请求方法、访问控制请求标头
cors.exposed.headers
访问控制允许来源,访问控制允许凭据
cors.support.credentials
真的
cors.preflight.maxage
10
克斯菲尔特
*
由于这一变化,我的所有路线都返回404,从同一来源以及从另一来源返回。有人知道这是什么原因吗? 我还尝试了最基本的TomEE cors过滤器:但这只会导致相同的结果


提前感谢。

您是否打算设置
metadata complete=“true”
?它会停用一些扫描,因此您可能希望将其设置为false


您在服务器上部署了什么?这个web.xml没有servlet,所以我想它应该是扫描过的东西吗?

您打算设置
metadata complete=“true”
?它会停用一些扫描,因此您可能希望将其设置为false


您在服务器上部署了什么?这个web.xml没有servlet,所以我想它应该是扫描过的东西?

您已经声明了两次筛选器。删除冗余声明(筛选器和筛选器映射)。在您的第二次声明中,url模式只是“*”,但它应该是“/*”。我也注意到了这一点,并从那时起对其进行了更改,但这并不能解决问题。@SvetlinZarev您有什么线索吗?您已经声明了两次筛选器。删除冗余声明(筛选器和筛选器映射)。在您的第二个声明中,url模式只是“*”,但它应该是“/*”,我也注意到了这一点,并从那时起对其进行了更改,但这并不能解决问题。@SvetlinZarev您有什么线索吗?