我的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>
虽然我已导入安全性3.1.1 jar
,但我无法将其添加到其中<http>
<intercept-url pattern='/home*' access='ROLE_USER,ROLE_ADMIN' />
</http>
答案 0 :(得分: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及其架构位置。