【问题标题】:Spring MVC 3.1 - Namespace errorSpring MVC 3.1 - 命名空间错误
【发布时间】:2012-03-20 15:57:10
【问题描述】:

我的dispatcher-servlet.xml中有以下内容

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:beans="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/mvc
                           http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
                           http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-3.1.xsd
                           http://www.springframework.org/schema/util
                           http://www.springframework.org/schema/util/spring-util-3.1.xsd">

XML 验证失败说

发现从元素“context:component-scan”开始的无效内容。 '{"http://www.springframework.org/schema/mvc":argument-resolvers, "http://www.springframework.org/ 之一 schema/mvc":return-value-handlers}' 是预期的。

我已经检查了定义在 http://www.springframework.org/schema/mvc/ 一切似乎都很好。以前我使用的是 Spring mvc 3.0,它没有遇到任何问题。我所有的 jar 文件都直接在WEB-INF/lib 中。有什么想法吗?

更新

这是验证失败的行&lt;context:component-scan base-package="com" /&gt;是的,所有使用的 jar 都来自 Spring 3.1

【问题讨论】:

  • 都是3.1版本的jar吗?
  • @skaffman:已更新问题以提供信息

标签: java spring spring-mvc


【解决方案1】:

可能是错误的,但是查看架构和给出的错误,您是否尝试将&lt;context:component-scan base-package="com" /&gt; - 元素放在&lt;mvc:annotation-driven&gt; &lt;/mvc:annotation-driven&gt; -tag 中,或者忘记关闭&lt;mvc:annotation-driven&gt; -tag?将组件扫描放在标签之外或正确关闭&lt;mvc:annotation-driven&gt; -tag。

【讨论】:

  • 非常感谢。是的,我忘记关闭 。傻我。半个多小时以来,我一直试图找出问题所在。必须检查我的眼睛:P
猜你喜欢
  • 1970-01-01
  • 2011-03-05
  • 1970-01-01
  • 1970-01-01
  • 2013-06-17
  • 2012-10-24
  • 1970-01-01
  • 2013-02-07
相关资源
最近更新 更多