<div class="item active" th:if="${iterStat.index==0}" th:each="img,iterStat:${pics}">html
<img th:src="${img.path}" style="width: 303px;height: 171px;"/>spa
</div>
解说:
对arrayList对象pics遍历,使用img做为接受参数接收,使用iterStat做为pics下标值,经过iterStat.index获得当前所处下标值;
经过th:src="${img.path}"获得对象中图片路径设置图片显示图code
<tr th:each="prod,iterStat : ${prods}" th:class="${iterStat.odd}? 'odd'"> <td th:text="${prod.name}">Onions</td> <td th:text="${prod.price}">2.41</td> <td th:text="${prod.inStock}? #{true} : #{false}">yes</td> </tr>
解说:
判断下标是否未奇数,设置tr样式htm