2013-08-28 111 views
0

大家好羅爾斯我有一個春天的安全應用春季安全除了匿名

<http auto-config="true"> 
    <intercept-url pattern="/**" /> 
    <form-login authentication-failure-handler-ref="authenticationFailureHandler" authentication-success-handler-ref="authenticationSuccessHandler" login-page="${loginUrl}" authentication-failure-url="${loginUrl}" /> 
    <logout logout-url="/logout" invalidate-session="true" success-handler-ref="logoutSuccessHandler" /> 
    <anonymous enabled='false'/> 
</http> 

但匿名用戶沒有被攔截,我怎樣才能讓所有角色,但不ROLE_ANONYMOUS?

回答

2

嘗試IS_AUTHENTICATED_FULLY

<intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY" /> 

可以使用規劃環境地政司表達做同樣的事情:

<http auto-config="true" use-expressions="true"> 
    ...   
    <intercept-url pattern="/**" access="isAuthenticated()" />   
    ... 
</http> 

所有可用的表達式列here。通常SpEL表達式更靈活。