Issue
How to get enum in thymeleaf in kotlin project?
This is an enum file.
<!-- language: lang-kotlin -->
enum class SessionEnum(val displayValue: String) {
USERNAME("username")
}
I tried to get the enum value in thymeleaf in this way, but it failed.
<p>Login User:<span th:text="${T(com.project.example.authapp.types.SessionEnum).USERNAME)}"></span></p>
I would appreciate it if someone with a good understanding of kotlin could tell me.
Solution
You have an extra )
in the template. Also, if you want to show displayValue
i.e. "username" instead of "USERNAME" add .displayValue
:
<p>Login User:<span th:text="${T(com.project.example.authapp.types.SessionEnum).USERNAME.displayValue}"></span></p>
Answered By - Jan Itor
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.