在百里香中结合条件和迭代 [英] Combining conditions and iterations in thymeleaf
问题描述
我想使用 thymeleaf 和 bootstrap 生成一个产品列表,以便我连续拥有三个产品.
如果不是为了行,我会做这样的事情:
<div class="product"><h3 th:text="${product.name}">产品名称</h3><img th:src="${product.imagePath}"/>
但我想将每三个产品包含在一个 <div class="row">
中,我就是不知道如何做到这一点.有没有其他人偶然发现这个问题?如何在不显式在控制器中创建三个产品列表的情况下实现所需的输出?
期望的输出
<div class="col-sm-4"><div class="product"><h3>产品 1 名称</h3><img src="/path/to/image"/>
<div class="col-sm-4"><div class="product"><h3>产品2名称</h3><img src="/path/to/image"/>