Spring 3.0.3带有mvc:resources的SAXParseException

时间:2012-11-21 10:50:30

标签: xml spring-mvc

我的问题与此one非常相似。然而,我找不到错误: - (

这是我的myapp-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:p="http://www.springframework.org/schema/p"
    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
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">

    <context:component-scan base-package="de.myapp.controller" />

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

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

</beans>

我已经多次检查了xml,甚至是this问题中提到的答案。我仍然得到Line 15 in XML document from ServletContext resource [/WEB-INF/myapp-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:resources'.

1 个答案:

答案 0 :(得分:0)

只需使用版本&gt; 3.0.3,因为从3.0.4版开始提供此功能!我尝试使用3.2版本在我的问题中引用的解释。它完美无缺!