【发布时间】:2016-08-26 11:42:51
【问题描述】:
我有一个<div> 块,我需要根据条件将其设置为display:none 或display:block。 html看起来是这样的,
<div style="display:none;">
//some html block content
</div>
我在 thymeleaf 中尝试过以下代码,
<div th:style="${condition} == 'MATCH' ? display:block : display:none">
//some html block content
</div>
但是上面的表达式不起作用。抛出 org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: 错误消息。
我可以通过 th:classappend 设置一些类并使其工作,但想知道 elvis/三元运算符是否支持 thymeleaf th:style 标签。
【问题讨论】:
标签: thymeleaf conditional-operator