我有一个问题,当我在dispatcher-servlet.xml中添加以下代码时,就会出现此错误
<mvc:cors>
<mvc:mapping path="/**" />
</mvc:cors>
下面是我完整的dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<!-- Content for controller,service and dao package -->
<context:component-scan base-package="net.abyres.mym.*" />
<context:component-scan base-package="net.abyres.mym.controller" />
<context:component-scan base-package="net.abyres.mym.service" />
<context:component-scan base-package="net.abyres.mym.sam.dao" />
<context:component-scan base-package="net.abyres.mym.admin.dao" />
<context:component-scan base-package="net.abyres.mym.api" />
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="-1"/>
<!-- <property name="maxUploadSize" value="52428800"/> -->
</bean>
<!-- To process view for pdf using iText
<bean id="viewResolver1" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="order" value="1"/>
<property name="basename" value="views"/>
</bean>
-->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- To control priority of view in modelandview use for iText
<property name="order" value="2"/> -->
<!-- New -->
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<!-- End of New -->
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<!-- Files concerned: -->
<!-- /WEB-INF/ApplicationMessageSource_my.properties -->
<!-- /WEB-INF/ApplicationMessageSource_en.properties -->
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>/WEB-INF/languages/ApplicationMessageSource</value>
</list>
</property>
<property name="defaultEncoding" value="UTF-8" />
<property name="fallbackToSystemLocale" value="false"/>
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="my" />
</bean>
<bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"></bean>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jacksonMessageConverter"/>
</list>
</property>
</bean>
<mvc:resources mapping="/resources/**" location="/resources/"/>
<mvc:annotation-driven/>
<mvc:interceptors>
<bean id="webContentInterceptor"
class="org.springframework.web.servlet.mvc.WebContentInterceptor">
<property name="cacheSeconds" value="0"/>
<property name="useExpiresHeader" value="true"/>
<property name="useCacheControlHeader" value="true"/>
<property name="useCacheControlNoStore" value="true"/>
</bean>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"
p:paramName="locale"/>
</mvc:interceptors>
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<bean class="net.abyres.mym.utility.PagePopulationInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
<mvc:interceptors>
<bean class="net.abyres.mym.utility.AuditInterceptor"></bean>
</mvc:interceptors>
<mvc:default-servlet-handler/>
<mvc:view-controller path="/" view-name="welcome" />
<mvc:default-servlet-handler/>
<mvc:cors>
<mvc:mapping path="/**" />
</mvc:cors>
错误如下所示
cvc-complex-type.2.4.c:匹配的通配符是严格的,但是找不到元素'mvc:cors'的声明。
我真的希望有人能帮助我。非常感谢。