僅當用戶通過身份驗證時,我無法在JSP頁面中顯示註銷鏈接。這裏是例外,我在這條線的JSP頁面:Spring Security - 在應用程序上下文中找不到可見的WebSecurityExpressionHandler實例
<sec:authorize access="isAuthenticated()">
例外:
Stacktrace:
....
root cause
javax.servlet.jsp.JspException: No visible WebSecurityExpressionHandler instance could be found in the application context. There must be at least one in order to support expressions in JSP 'authorize' tags.
org.springframework.security.taglibs.authz.AuthorizeTag.getExpressionHandler(AuthorizeTag.java:100)
org.springframework.security.taglibs.authz.AuthorizeTag.authorizeUsingAccessExpression(AuthorizeTag.java:58)
這裏是我的應用程序上下文的security.xml:
<http auto-config='true' >
<intercept-url pattern="/user/**" access="ROLE_User" />
<logout logout-success-url="/hello.htm" />
</http>
<beans:bean id="daoAuthenticationProvider"
class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<beans:property name="userDetailsService" ref="userDetailsService" />
</beans:bean>
<beans:bean id="authenticationManager"
class="org.springframework.security.authentication.ProviderManager">
<beans:property name="providers">
<beans:list>
<beans:ref local="daoAuthenticationProvider" />
</beans:list>
</beans:property>
</beans:bean>
<authentication-manager>
<authentication-provider user-service-ref="userDetailsService">
<password-encoder hash="plaintext" />
</authentication-provider>
</authentication-manager>
我明白我可以在http標記中使用use-expression =「true」,但這意味着我必須在intercept-url標記和java代碼中使用表達式。有沒有解決方法?
一個無關的觀察。您的配置中的「daoAuthenticationProvider」和「authenticationManager」未被使用。 – 2012-07-21 22:41:54