使用Spring授权标签检查用户是否登录时出错? [英] Error using Spring authorize tag to check to see if user is logged in?
本文介绍了使用Spring授权标签检查用户是否登录时出错?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试测试用户是否已登录,我正在使用以下代码:
Trying to test to see if a user is logged in I am using the following code:
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<sec:authorize access="isAuthenticated()">
YES, you are logged in!
</sec:authorize>
但是我得到了以下错误提示?
But I am getting the following erorr?
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.
at org.springframework.security.taglibs.authz.AuthorizeTag.getExpressionHandler(AuthorizeTag.java:100)
at org.springframework.security.taglibs.authz.AuthorizeTag.authorizeUsingAccessExpression(AuthorizeTag.java:58)
at org.springframework.security.taglibs.authz.AuthorizeTag.doStartTag(AuthorizeTag.java:48)
推荐答案
要使用表达式保护单个URL,首先需要将元素中的use-expressions属性设置为true
To use expressions to secure individual URLs, you would first need to set the use-expressions attribute in the element to true
<http use-expressions="true">
请参阅Spring Security文档
这篇关于使用Spring授权标签检查用户是否登录时出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文