Ошибка: "schemaLocation value *** должно иметь четное количество URI". на пространствах имен в диспетчере spring
Я получал следующую ошибку
<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.
и мой диспетчерский сервлет имел следующие пространства имен
<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 Schema для пространства имен.
В основном при вводе:
xmlns:expns="http://www.example.com"
xsi:schemaLocation="http://www.example.com
http://www.example.com/schema/example.xsd"
Вы говорите: "Я собираюсь использовать префикс expns
для элементов пространства имен http://www.example.com
. Также вы можете проверить эти элементы, получить файл схемы XSD для http://www.example.com
в 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"
И так далее.
Вот почему мне нужен даже номер.
Более подробную информацию и примеры можно найти здесь.