【问题标题】:Security Namespace Configuration in Spring 3.2.4Spring 3.2.4 中的安全命名空间配置
【发布时间】:2016-01-17 20:08:36
【问题描述】:

我有一个 Spring 3.2.4 应用程序,我想添加 Spring Security,所以我添加了 jar spring-security-web-4.0.2.RELEASEspring-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


【解决方案1】:

这里

<?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:security="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">


    <security:http auto-config="true">    
      <!-- enable csrf protection -->
      <security:csrf/>
    </security:http>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多