问题描述
th:class动态添加CSS class会覆盖现有class属性,导致class较多时,表达式过长。
官方文档
https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#appending-and-prepending
解决方案
th:classappend:用于在不覆盖现有属性的情况下向元素添加CSS class。
<tr th:each="prod : ${prods}" class="row" th:classappend="${prodStat.odd}? 'odd'">
扩展
参考文章
https://blog.csdn.net/weixin_44357646/article/details/100837365