【发布时间】:2013-01-20 10:06:21
【问题描述】:
我正在尝试使用Web Security Expressions,但是当我在单元测试中加载上下文时,我得到org.xml.sax.SAXParseException: The markup declarations contained or pointed to by the document type declaration must be well-formed
我的上下文文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sec="http://www.springframework.org/schema/security"
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-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
// various beans here
<sec:http use-expressions="true">
<sec:intercept-url pattern="/admin*"
access="hasRole('admin') and hasIpAddress('192.168.1.0/24')"/>
</sec:http>
</beans>
如果我不包含 <sec:http> 标签,我不会收到错误消息。如果我只包含<sec:http/>,我会收到错误消息。
在我的 pom 中,我包含了:
<dependancy>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.0.5.RELEASE</version>
</dependancy>
【问题讨论】:
-
您对springframework.org/schema/security/spring-security-3.0.xsd URL(在您执行测试的环境中)有任何问题吗?
-
我得到了 404 以及我使用的所有其他 xsd。我假设它是在运行时从 jar 中获取模式?不知道如何检查它是否可以与我使用的其他人相比。
-
这个通常是通过网络加载的。我没有任何问题(可以在我的网络浏览器中查看)。
-
这似乎是这个问题的表亲:stackoverflow.com/questions/2161050/…
标签: java spring junit spring-security