仅当用户通过身份验证时,我才在JSP页面中显示注销链接时遇到问题。下面是我在JSP页面的这一行中遇到的异常:
<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)
下面是我的application-context-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代码中使用expression。有解决办法吗?
发布于 2012-07-22 02:53:44
您可以只向您的应用程序上下文添加一个
<bean id="webexpressionHandler" class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler" />
但最简单的方法是在<http>
配置中启用表达式,系统将为您添加一个表达式。这只意味着您必须在该块中使用表达式,而不是在@Secured
方法注释等Java代码中使用表达式。
https://stackoverflow.com/questions/11594104
复制相似问题