为什么这个spring配置文件不能解析mvc:resources元素

时间:2012-01-31 19:52:54

标签: spring spring-mvc

我无法克服这个错误。 mvc xsd是正确的,并验证资源元素是否存在。为什么这个spring配置文件不能解析mvc:resources元素

SAXParseException:cvc-complex-type.2.4.c:匹配的通配符是strict,但是找不到元素'mvc:resources'的声明

我正在使用springframework v3.0.2

<beans 
xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:task="http://www.springframework.org/schema/task"
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/task 
http://www.springframework.org/schema/task/spring-task-3.0.xsd 
http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

    <context:component-scan annotation-config="true" base-package="com.auto"/>

    <mvc:annotation-driven />
    <mvc:view-controller path="/" view-name="index"/>

    <mvc:resources location="/resources/" mapping="/resources/**"/>

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

2 个答案:

答案 0 :(得分:3)

mvc:资源是在3.0.4中引入的,而您使用的是3.0.2。请参阅此问题的已接受答案Spring serving static content with mvc:resources, invalid xsd

答案 1 :(得分:0)

确保部署了包含spring-mvc-3.0.xsd的jar。 (当我记得没错时,它是spring-mvc.jar