【问题标题】:Why does this spring config file not resolve the mvc:resources element为什么这个 spring 配置文件不能解析 mvc:resources 元素
【发布时间】:2012-01-31 19:52:54
【问题描述】:

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

SAXParseException: cvc-complex-type.2.4.c: 匹配通配符是严格的,但找不到元素“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>

【问题讨论】:

    标签: spring spring-mvc


    【解决方案1】:

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

    【讨论】:

    • 谢谢@digitaljoel 做到了
    • 当然。我敏锐地意识到这个问题,因为它在几个月前困扰着我。
    【解决方案2】:

    确保已部署包含 spring-mvc-3.0.xsd 的 jar。 (我没记错的话是spring-mvc.jar

    【讨论】:

      猜你喜欢
      • 2013-08-27
      • 1970-01-01
      • 2013-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-11
      • 1970-01-01
      相关资源
      最近更新 更多