Java cvc-complex-type.2.4.c:匹配的通配符是严格的,但找不到元素'mvc:annotation-driven'错误的声明

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19218122/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 15:10:30  来源:igfitidea点击:

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven' error

javaspringspring-mvcspring-security

提问by Abhishek Singh

I have added the spring-security-config-3.1.0.RC3.jar in my lib folder and i still get this error. What can be possible reason ??

我在我的 lib 文件夹中添加了 spring-security-config-3.1.0.RC3.jar ,但我仍然收到此错误。可能的原因是什么??

Here is my dispatcher-servlet.xml

这是我的 dispatcher-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans     
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/context 
   http://www.springframework.org/schema/context/spring-context-3.0.xsd">

   <context:component-scan base-package="com.tcs.rspm.controller" />
<mvc:annotation-driven /> 
   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/webpages/" />
      <property name="suffix" value=".jsp" />
   </bean>

</beans>

采纳答案by eis

You have this:

你有这个:

xmlns:mvc="http://www.springframework.org/schema/mvc"

but you're not mentioning it here:

但你没有在这里提到它:

xsi:schemaLocation="
http://www.springframework.org/schema/beans     
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

To fix that, you should have

要解决这个问题,你应该有

http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd

there as well, like

也有,比如

xsi:schemaLocation="
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans     
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

Note: it is actually common that schema references don't mention Spring version to allow for easier upgrading, so you should use references like http://www.springframework.org/schema/context/spring-context.xsdinstead of the ones having -3.0in the name.

注意:实际上,模式引用不提及 Spring 版本是很常见的,以便更容易升级,因此您应该使用类似的引用http://www.springframework.org/schema/context/spring-context.xsd而不是名称中包含的引用-3.0