Spring v3找不到元素'mvc:resources'的声明
Tomcat:v6
Spring Tools Suite:v2.7.2
Spring Framework: spring-webmvc-3.0.5
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: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>
web.xml partial code
<servlet-mapping> <servlet-name>duckapp</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Servlet Purpose
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
回答:
在你的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中的实际架构位置。
以上是 Spring v3找不到元素'mvc:resources'的声明 的全部内容, 来源链接: utcz.com/qa/402378.html