Tomcat:v6
Spring Tools Suite:v2.7.2
Spring框架:spring-webmvc-3.0.5
<?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/mvc/spring-mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<mvc:annotation-driven />
<mvc:resources mapping="/resources/**" location="/resources" />
<context:component-scan base-package="com.app.mvc" />
</beans>
<servlet-mapping>
<servlet-name>duckapp</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
web.xml将所有URL映射到servlet,但mvc:resources映射静态文件除外。
cvc-complex-type.2.4.c:匹配的通配符很严格,但是找不到元素'mvc:annotation-driven'的声明。app-servlet.xml / app / www / WEB-INF
cvc-complex-type.2.4.c:匹配的通配符是严格的,但是找不到元素'mvc:resources'的声明。app-servlet.xml / app / www / WEB-INF
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd不包含元素资源
如果替换为http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd仍然无法正常工作,并且根据spring 3.05的jar文件可能无法正常工作
mvc:resources出现在春季v3.0.4中,但没有新的xsd
如何解决编译错误以使mvc:resources正常工作?
我已经为此花了大约2个小时的时间,还没有确切的答案...
在您的Spring上下文中,xml mvc名称空间url应该与schemaLocation中的url相匹配。像这样:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
这是标准的XML名称空间声明。名称空间url是一种唯一ID,然后将其映射到xsi:schemaLocation中的实际架构位置。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句