当我尝试在Spring-Security配置上使用hasAnyRole时出现错误。
我的applicationContextSecurity.xml
<?xml version="1.0" encoding="UTF-8"?>
<b:beans xmlns="http://www.springframework.org/schema/security"
xmlns:b="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<http use-expressions="true">
<intercept-url pattern="/admin/" access="ROLE_ADMINISTRADOR" />
<intercept-url pattern='/paginas/' access="hasAnyRole('ROLE_USUARIO', 'ROLE_ADMINISTRADOR')"/>
<form-login login-page="/publico/login.xhtml"
always-use-default-target="true" default-target-url="/paginas/agenda/index.xhtml"
authentication-failure-url="/publico/login.jsf?login_error=1"/>
<logout/>
<remember-me />
</http>
<authentication-manager>
<authentication-provider>
<jdbc-user-service data-source-ref="sincronizaDataSource"
authorities-by-username-query="SELECT u.login, p.permissao
FROM usuario u, usuario_permissao p
WHERE u.id = p.usuario
AND u.login = ?"
users-by-username-query="SELECT login, senha, ativo
FROM usuario
WHERE login = ?" />
</authentication-provider>
</authentication-manager>
然后我收到了这个错误:
引起:java.lang.IllegalArgumentException:预期[/ paginas /]的单个表达式属性 在org.springframework.util.Assert.isTrue(Assert.java:65) 在org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource.processMap(ExpressionBasedFilterInvocationSecurityMetadataSource.java:43) 在org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource。(ExpressionBasedFilterInvocationSecurityMetadataSource.java:30) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:408) 在org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126) ......还有31个