Spring v3没有为元素'mvc:resources'找到声明 [英] Spring v3 no declaration can be found for element 'mvc:resources'

查看:211
本文介绍了Spring v3没有为元素'mvc:resources'找到声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Tomcat:v6

Tomcat: v6

Spring Tools Suite:v2.7.2

Spring Tools Suite: v2.7.2

Spring Framework:spring-webmvc-3.0.5

Spring Framework: spring-webmvc-3.0.5

 <?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: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/spring-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">

      <mvc:annotation-driven />

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

      <context:component-scan base-package="com.app.mvc" />

 </beans>



web.xml部分代码



web.xml partial code

<servlet-mapping>
    <servlet-name>duckapp</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>



Servlet用途



web.xml地图除了mvc:resources映射静态文件外,servlet的所有URL。

Servlet Purpose

web.xml maps all urls to the servlet with the exception of mvc:resources mapping static files.


  • cvc-complex-type.2.4.c:匹配的通配符是strict,但是找不到元素'mvc:annotation-driven'的声明。 app-servlet.xml / app / www / WEB-INF

  • cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'. app-servlet.xml /app/www/WEB-INF

cvc-complex-type.2.4.c:匹配的通配符是严格的,但没有声明可以找到元素'mvc:resources'。 app-servlet.xml / app / www / WEB-INF

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:resources'. app-servlet.xml /app/www/WEB-INF

如果被 http://www.springframework.org/schema/mvc/取代spring-mvc-3.1.xsd 仍然无法正常工作,可能无法根据spring 3.05的jar文件工作

If replaced by http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd still doesn't work and may not be working according to jar files of spring 3.05

mvc:资源出现在春季v3.0.4,但没有新的xsd

mvc:resources appeared in spring v3.0.4, but has no new xsd

如何修复编译错误以使mvc:资源正常工作?

How can I fix the compile errors to get mvc:resources working correctly?

我一直在挖掘大约2个小时,还没有可靠的答案。 ..

I've been digging around 2 hours for this, no solid answer yet...

推荐答案

在你的spring上下文中,xml mvc命名空间url应该匹配sch中的url emaLocation。这样的事情:

In your spring context xml mvc namespace url should match url in schemaLocation. Something like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="
         http://www.springframework.org/schema/mvc
         http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

这是标准的XML命名空间声明。命名空间url是一个唯一的id,然后映射到xsi:schemaLocation中的实际架构位置。

This is a standard XML namespace declaration. The namespace url is sort of an unique id, which is then mapped to the actual schema location in xsi:schemaLocation.

这篇关于Spring v3没有为元素'mvc:resources'找到声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆