我正在尝试使用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>
最佳答案
像这样的 DTD 文件
http://www.springframework.org/schema/security/spring-security-3.0.xsd
在每个解析操作期间必须可用于 XML 解析器。让它们可用,问题就会消失。
关于java - spring-security-web 加载上下文时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14708230/