Thymeleaf:添加到现有值而不是替换它们 [英] Thymeleaf: Add to existing values instead of replacing them

查看:35
本文介绍了Thymeleaf:添加到现有值而不是替换它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

示例:

 

应该导致任何一个

问候

解决方案

另一种方法是

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

Is there a way to tell Thymeleaf to add parameters to a tag instead of overriding them?

Example:

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

Should result in either

<div class="a b">

or

<div class="a c">

Regards

解决方案

Another way to do this would be

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

这篇关于Thymeleaf:添加到现有值而不是替换它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆