Spring MVC配置文件错误' mvc:resources'

时间:2016-05-10 17:46:25

标签: xml spring-mvc

- 配置文件 - cvc-complex-type.2.1:元素' mvc:resources'必须没有字符或元素信息项[children],因为类型的内容类型为空

 <?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:context="http://www.springframework.org/schema/context"
     xmlns:mvc="http://www.springframework.org/schema/mvc"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-2.5.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.2.xsd">  

     <!-- Enable annotation driven controllers, validation etc... -->  
    <mvc:annotation-driven></mvc:annotation-driven>  

    <context:component-scan base-package="com.dhs.controller">  
    </context:component-scan>  

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

    <mvc:resources location="/WEB-INF/staticContents/" mapping="/staticContents/**">  
    </mvc:resources>   

    </beans>  

3 个答案:

答案 0 :(得分:0)

<mvc:resources location="/WEB-INF/staticContents/" mapping="/staticContents/**">  
</mvc:resources> 

删除并将上述行写为

<mvc:resources location="/WEB-INF/staticContents/" mapping="/staticContents/**"/>

并且没有标记错误

答案 1 :(得分:0)

DHS,

我认为你编辑了一些代码。

<!-- Handles HTTP GET requests for /resources/** by efficiently serving 
    up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />

您搜索到网络应用程序文件夹结构。

答案 2 :(得分:0)

如果可以升级,请升级到spring-mvc 4,例如在spring-mvc 4中解决。 http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd