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
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven' error
提问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.xsd
instead of the ones having -3.0
in the name.
注意:实际上,模式引用不提及 Spring 版本是很常见的,以便更容易升级,因此您应该使用类似的引用http://www.springframework.org/schema/context/spring-context.xsd
而不是名称中包含的引用-3.0
。