当我尝试在 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>
最佳答案
没有命名空间作为“资源”。使用以下标签,
<mvc:resources mapping="/resources/**" location="/resources/"/>
要使其正常工作,请同时添加 mvc 命名空间
<?xml version="1.0" encoding="UTF-8"?>
<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
......
关于java - Spring MVC 模式给出 SAXParseException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28059844/