【发布时间】:2016-01-17 20:08:36
【问题描述】:
我有一个 Spring 3.2.4 应用程序,我想添加 Spring Security,所以我添加了 jar spring-security-web-4.0.2.RELEASE 和 spring-security- config-4.0.2.RELEASE.jar在项目中
我想加入
<http auto-config="true">
<!-- enable csrf protection -->
<csrf/>
</http>
在applicationContext.xml 文件中,我还包含了安全命名空间
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:http="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-4.0.xsd">
但是我收到了这个错误:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'http'. One of '{"http://
www.springframework.org/schema/beans":description, "http://www.springframework.org/schema/
beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/
schema/beans":bean, WC[##other:"http://www.springframework.org/schema/beans"]}' is expected.
【问题讨论】:
-
您还需要
spring-config旁边的那个使用spring 中的无版本模式而不是版本化模式。最后,您声明了security命名空间而不是http命名空间。将security重命名为http或使用security:而不是http:。
标签: spring spring-mvc spring-security