Thymeleaf compare #locale expression object with string

我们两清 提交于 2019-12-01 11:27:47
Armando Pérez

Based on the answer posted by David_Garcia, I could resolve my issue this way:

th:class="__${#locale}__=='en'?'active':''

This is a issue that I told to the guys of thymeleaf time ago.

You need to resolve first the #locale before comparing it with "en". You can do that adding 2 underscore at the beggining and end to the expresion that you want to resolve first. In your case will be something like this:

th:call="$({__#locale__}=='en'?'active':'')"

I used like this

th:text="${#locale.toString()}=='in'?'active':'inactive'"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!