0

我正在尝试使用网络安全表达式,但是当我在单元测试中加载上下文时,我得到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>
4

2 回答 2

1

像这样的 DTD 文件

http://www.springframework.org/schema/security/spring-security-3.0.xsd

在每个解析操作期间必须可用于 XML 解析器。让它们可用,问题就会消失。

于 2013-02-05T14:00:53.540 回答
0

原来弹簧安全的模式在spring-security-config罐子里。我需要那种依赖。

于 2013-02-05T14:21:38.293 回答