【问题标题】:Error in Spring MVC Config File 'mvc:resources'Spring MVC 配置文件“mvc:resources”中的错误
【发布时间】:2016-05-10 17:46:24
【问题描述】:

--配置文件--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>  

【问题讨论】:

    标签: xml spring-mvc


    【解决方案1】:
    <mvc:resources location="/WEB-INF/staticContents/" mapping="/staticContents/**">  
    </mvc:resources> 
    

    去掉上面一行写成

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

    并且不会有标记的错误

    【讨论】:

      【解决方案2】:

      dhs,

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

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

      您搜索到 web-app 文件夹结构。

      【讨论】:

        【解决方案3】:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-01-29
          • 2014-10-08
          • 1970-01-01
          • 2016-07-03
          • 1970-01-01
          • 1970-01-01
          • 2013-06-08
          相关资源
          最近更新 更多