Thymeleaf with Spring Security - how to check if user is logged in or not?
问题 I'm using Spring Boot with Thymeleaf and Spring Security. I've got a simple view with a login link. When the user logs in, I'd like to change login link to logout link. I tried: <div sec:authorize="#{isAuthenticated()}"> <a th:href="@{/logout}">Log out</a> </div> <div sec:authorize="#{isAnonymous()}"> <a th:href="@{/login}">Log in</a> </div> but it's not working - it displays both links. Best regards. EDIT: I solved it. I had to register Thymeleaf dialect. In order to do this, I created a new