首页 文章

Spring MVC 3.1 - 命名空间错误

提问于
浏览
1

我的 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 中 . 有任何想法吗?

Update

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

1 回答

  • 4

    可能是错的,但是查看模式和给出的错误,您是否可能尝试将 <context:component-scan base-package="com" /> -element放在 <mvc:annotation-driven> </mvc:annotation-driven> -tags中或忘记关闭 <mvc:annotation-driven> -tag?将组件扫描放在标签外部或正确关闭 <mvc:annotation-driven> -tag .

相关问题