问题描述:Description Resource Path Location Type
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'. springmvc.xml /taotao-manager-web/src/main/resources/spring line 11 XML Problem
分析:需要正确配置XML中的beans标签
先说下Spring3.0.4对静态资源访问的原理.通过<resources/>或者<mvc:resources/>元素,把mapping的URI注册到SimpleUrlHandlerMapping的urlMap中,key为mapping的URI pattern值,而value为ResourceHttpRequestHandler,这样就巧妙的把对静态资源的访问由HandlerMapping来得到ResourceHttpRequestHandler来处理返回,所以就支持classpath目录,jar包内静态资源的访问.
配置过程遇到的问题主要还是启动时BeanDefinitionXMLParser认不出<resources/>,<mvc:resources/>元素而抛出的异常.解决的方法一是正确的xmlns,xsi:schemaLocation.如下:
for <resources/>
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
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">
<resources mapping="/js/**" location="/js/" />
<resources mapping="/image/**" location="/image/" />
for <mvc:resources/>
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
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
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:resources mapping="/js/**" location="/js/" />
<mvc:resources mapping="/image/**" location="/image/" />
解决方法:将以上这些xml头替换源文件中的头文件,问题解决!!!!