java错误:spring dispatcher中命名空间上的“schemaLocation值***必须具有偶数个URI”
我犯了以下错误
<Ignored XML validation warning> org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 55;
SchemaLocation: schemaLocation value = 'http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx' must have even number of URI's.
我的DispatcherServlet具有以下名称空间
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
我用下面的内容来代替上面的内容
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
我的错误消失了
这是怎么发生的,谁能告诉我
# 1 楼答案
schemaLocation
属性为名称空间引用XML模式文档基本上,当您键入时:
您的意思是:“我将使用前缀>中获取
expns
作为名称空间http://www.example.com
的元素。另外,为了验证这些元素,您可以在^{http://www.example.com
的XSD模式文件换句话说,格式是:
等等
这就是为什么它必须给我一个偶数
有关更多信息和示例,请参见here
# 2 楼答案
@acdcjunior解释正确,要解决OP的问题,需要添加缺少的命名空间p的schemaLocation
另请注意,如果命名空间定义和schemaLocation定义的顺序不同,也会出现此警告