简体   繁体   中英

spring-security-web error loading context

I am attempting to use Web Security Expressions however when I load the context in my unit test I get org.xml.sax.SAXParseException: The markup declarations contained or pointed to by the document type declaration must be well-formed

My context file looks like this:

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

If I don't include the <sec:http> tag I don't get the error. If I include just <sec:http/> I do get the error.

In my pom I have included:

<dependancy>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-web</artifactId>
    <version>3.0.5.RELEASE</version>
</dependancy>

DTD files like this one

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

must be available for XML parser during each parse action. Make them available and the problem will go away.

Turns out the schemas for spring security are in the spring-security-config jar. I needed that dependancy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM