How can I apply style to a div based on condition in thymeleaf?

蓝咒 提交于 2019-12-01 17:01:13
Lucky

Solved it while posting the question,

th:style="${condition ? 'display:block' : 'display:none'}" >

would produce the necessary conditional style. If condition is true display is set to block and none if condition is false.

For admin,

th:style="${role == 'ADMIN' ? 'display:block' : 'display:none'}" >

the style is set to display:block and for other roles the block is not displayed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!