Issue
How to append a class to an element with th:classappend
only if the user has a specific role?
Something like this:
<div th:classappend="${hasRole('EDITOR')?'glow':''}"></div>
I'm using Spring Boot, Spring Security and Thymeleaf.
Solution
You can use the request variable, which points to the current HttpServletRequest:
<div th:classappend="${#request.isUserInRole('EDITOR')?'glow':''}"></div>
Answered By - holmis83
Answer Checked By - Timothy Miller (JavaFixing Admin)