2

我的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>
4

1 回答 1

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 及其架构位置。

于 2014-03-30T12:09:36.313 回答