Java Thymeleaf:添加到现有值,而不是替换它们

Java Thymeleaf:添加到现有值,而不是替换它们,java,spring,spring-mvc,thymeleaf,Java,Spring,Spring Mvc,Thymeleaf,有没有办法告诉Thymeleaf向标记添加参数而不是覆盖它们 例如: <div class="a" th:class=${x ? 'b' : 'c'}> 这两种情况都会导致 <div class="a b"> 或 另一种方法是 th:attr="class=|a ${x ? 'b' : 'c'}|" th:classappend解决了这个问题。 th:attr="class=|a ${x ? 'b' : 'c'}|"

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

例如:

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

这两种情况都会导致

<div class="a b">



另一种方法是

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

th:classappend
解决了这个问题。
th:attr="class=|a ${x ? 'b' : 'c'}|"