cvc-complex-type.2.4.c:匹配的通配符是严格的,但是找不到元素'mvc:cors'

时间:2017-09-09 18:12:07

标签: java spring-mvc cors

在我的spring mvc中启用cors后,我收到以下错误。

org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 12; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:cors'.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:452)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3230)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1911)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:740)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:380)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2787)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)

以下是我的配置:

    <mvc:cors>
        <mvc:mapping path="/customers"
            allowed-origins="http://www.example.com, http://example.com"
            allowed-methods="POST, GET, PUT, DELETE"
            allowed-headers="Content-Type"
            exposed-headers="header-1, header-2"
            allow-credentials="false"
            max-age="6000" />
    </mvc:cors>

这是我的xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">


<mvc:cors>
            <mvc:mapping path="/customers"
                allowed-origins="http://www.example.com, http://example.com"
                allowed-methods="POST, GET, PUT, DELETE"
                allowed-headers="Content-Type"
                exposed-headers="header-1, header-2"
                allow-credentials="false"
                max-age="6000" />
        </mvc:cors>

</beans>

0 个答案:

没有答案