【发布时间】:2015-03-19 12:53:32
【问题描述】:
当我尝试在dispatcher-servlet.xml 中添加spring-mvc 架构时,我收到以下错误。我从 STS 中给出的 spring 示例中复制了 xml 文件。我正在使用 Spring 4.1.1。仅在使用 mvc 架构时才会出现此问题,而不会出现其他任何问题:
org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 116; Error: cos-all-limited.1.2: The minOccurs attribute of a model group with "all" compositor that is part of a pair that is the content type of a complex type definition must have the value one. The value "0" is incorrect.
我的文件是:
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<annotation-driven />
<resources mapping="/resources/**" location="/resources/" />
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/jsp/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="com.mj.cchp" />
</beans:beans>
【问题讨论】:
-
您提供的错误和架构似乎无关紧要。你确定吗?
-
@Keerthivasan 是的。仅当我包含 mvc 架构时才会发生此错误,否则不会发生此错误。
-
导入的 XSD 架构文件可能有问题。版本冲突。我认为您需要在
schemaLocation属性中提供适当版本的 XSD 的 URL。请检查一下 -
@Keerthivasan 不,没有必要。如果没有给出版本,它会自动获取最新版本。另外,我已经尝试提供版本,但仍然出现相同的错误。
-
哦,好的,谢谢您告诉我。我也不确定发生了什么。
标签: java xml spring spring-mvc