主题端有什么方法可以在Thymeleaf的th:if中校验是否已登录吗 #7052
-
主题端有什么方法可以在Thymeleaf的th:if中校验是否已登录吗 |
Beta Was this translation helpful? Give feedback.
Answered by
guqing
Nov 19, 2024
Replies: 3 comments
-
当前需求只需要判断已登录即可 |
Beta Was this translation helpful? Give feedback.
0 replies
-
@mjsoftking 有以下两种方式可以在主题端判断是否登录
<p th:if="${#authentication.name != 'anonymousUser'}">
已登录
</p> <div sec:authorize="isAuthenticated()">
已登录
</div> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
guqing
-
@guqing 感谢 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mjsoftking 有以下两种方式可以在主题端判断是否登录
${#authentication.name}
取值如果得到 anonymousUser 表示未登录,否则会得到已登录用户的用户名