java - 错误 : "schemaLocation value *** must have even number of URI' s. “在 Spring 调度程序中的命名空间上

标签 java xml spring-mvc xsd

我收到以下错误

<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.

我的调度器 servlet 有以下命名空间

<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">  

我的错误消失了。
这是怎么回事,谁能告诉我??

最佳答案

schemaLocation 属性引用命名空间的 XML 模式文档。

基本上在你输入时:

xmlns:expns="http://www.example.com"
xsi:schemaLocation="http://www.example.com
                    http://www.example.com/schema/example.xsd"

你是说:"我要使用前缀 expns 命名空间的元素 http://www.example.com。此外,为了验证这些元素,请获取 http://www.example.com 的 XSD 架构文件 in http://www.example.com/schema/example.xsd"

所以,换句话说,格式是:

xsi:schemaLocation="namespace-a   where_to_get_the_xsd_for_namespace-a
                    namespace-b   where_to_get_the_xsd_for_namespace-b
                    namespace-c   where_to_get_the_xsd_for_namespace-c"

等等。

这就是为什么它必须是一个偶数


更多信息和示例可以找到 here .

关于java - 错误 : "schemaLocation value *** must have even number of URI' s. “在 Spring 调度程序中的命名空间上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16662953/

相关文章:

php - 如何从 MediaWiki API 获取主体图像?

java - 使用 Thymeleaf 显示当前服务网关 url

java - Spring MVC : Advanced annotation based mapping

java - Spring MVC错误

java - Spring Boot Data JPA 问题——创建具有名称的 bean 时出错

javascript - Visual Studio 2015 - Html 编辑器 - 自定义架构?

java - 如何在属性类型为varchar(254)的数据库中对长字符串进行编码?

android - 如何在 androidplot 中配置 "PointLabelFormatter"?

java - 如何告诉 Maven 包含 jar 依赖项,而不是 Eclipse 中的子项目源目录?

Java - 如何将 JPG/PNG 文件从资源(可绘制)添加到布局?