简体   繁体   English

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

[英]Thymeleaf: Add to existing values instead of replacing them

Is there a way to tell Thymeleaf to add parameters to a tag instead of overriding them? 有没有办法告诉Thymeleaf将参数添加到标签而不是覆盖它们?

Example: 例:

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

Should result in either 应该导致

<div class="a b">

or 要么

<div class="a c">

Regards 问候

另一种方法是

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 intellij 的现有项目中添加 vaadin 而不是 thymeleaf? - How to add vaadin instead of thymeleaf in existing project in intellij? 设置实体数据会添加到现有数据中,而不是替换补丁请求中的所有现有值 - setting entity data adds to existing ones instead of replacing all existing values on Patch request 如何添加onClickListener而不是替换侦听器? - how to add onClickListener instead of replacing listener? 如何将文本添加到textArea而不是替换它 - How to add text to a textArea instead of replacing it 如何将现有文件夹添加到android并使用它们? - How to add existing folder to android and use them? 如何将字符串添加到textPane而不是设置它们? - How to add strings to textPane instead of setting them? 动态向现有JTable添加值 - Add values to existing JTable dynamically JShell - 如何在不替换此类的情况下将方法添加到现有类? - JShell - How to add method to existing class without replacing this class? 将多个数据库(而不是一个)添加到现有应用程序 - Add multiple databases (instead of one) to an existing application Maven JAR 插件 3.0.2 错误:您必须使用分类器将补充工件附加到项目而不是替换它们 - Maven JAR Plugin 3.0.2 Error: You have to use a classifier to attach supplemental artifacts to the project instead of replacing them
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM