【问题标题】:Fixing http tag in Spring bean config file修复 Spring bean 配置文件中的 http 标签
【发布时间】:2014-05-09 17:43:00
【问题描述】:

我的bean配置文件如下

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
    http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
 ">


</beans:beans>

虽然我已导入 security 3.1.1 jar,但我无法将以下内容添加到其中

<http> 
  <intercept-url pattern='/home*' access='ROLE_USER,ROLE_ADMIN' />
</http>

【问题讨论】:

    标签: spring spring-security spring-security-ldap


    【解决方案1】:

    您可能希望使用security 命名空间。另一种方法是将 security 设为默认命名空间 - 您必须决定是否要这样做。

    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:security="http://www.springframework.org/schema/security"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
    
        <security:http>
            <security:intercept-url pattern='/home*' access='ROLE_USER,ROLE_ADMIN'/>
        </security:http>    
    </beans:beans>
    

    我不仅在您使用的标签前面添加了security:,而且还在顶部添加了 xmlns:security 及其架构位置。

    【讨论】:

    • 谢谢。但刚刚出现警告。无法找到元素安全的 Spring 命名空间处理程序:http
    • 请解释一下:你用的是什么IDE?您是在编写 servlet 还是您自己的可运行 jar?请显示您用于运行所有内容的代码。
    • 通过在每个子标签的开头添加security:作为security:logout解决了问题
    猜你喜欢
    • 1970-01-01
    • 2020-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-11
    • 2011-03-19
    • 2013-06-01
    相关资源
    最近更新 更多