【发布时间】:2016-02-18 17:12:12
【问题描述】:
我正在寻找一种使用 Thymeleaf 将 html 元素动态附加到其他 html 元素的方法。
考虑以下几点:
<ol class="ol1" />
<ol class="ol2" />
<ol class="ol3" />
<iterate th:each="model">
<!-- ol1.append(model.name) -->
<!-- ol2.append(model.type) -->
<!-- ol3.append(model.something) -->
</iterate>
我知道一个可能的解决方案是有 3 个循环,一个嵌套在每个 <ol> 标记中,如下所示:
<ol class="ol1">
<iterate th:each="model">
model.name
</iterate>
</ol>
<ol class="ol2">
<iterate th:each="model">
model.type
</iterate>
</ol>
<ol class="ol3">
<iterate th:each="model">
model.something
</iterate>
</ol>
上述解决方案对我来说太低效了。
那么,Thymeleaf 是否提供了在这种情况下只执行一次迭代的功能?
【问题讨论】:
标签: html loops iteration thymeleaf