【问题标题】:Thymeleaf: Add to existing values instead of replacing themThymeleaf:添加到现有值而不是替换它们
【发布时间】:2016-06-02 11:44:57
【问题描述】:

有没有办法告诉Thymeleaf 向标签添加参数而不是覆盖它们?

例子:

 <div class="a" th:class=${x ? 'b' : 'c'}>

应该会导致

<div class="a b">

<div class="a c">

问候

【问题讨论】:

  • th:classappend 解决了问题。

标签: java spring spring-mvc thymeleaf


【解决方案1】:

另一种方法是

th:attr="class=|a ${x ? 'b' : 'c'}|"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-20
    • 2015-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-06
    相关资源
    最近更新 更多