thymeleaf标签th:each的使⽤
<div class="item active" th:if="${iterStat.index==0}" th:each="img,iterStat:${pics}">
<img th:src="${img.path}" />
</div>
解说:
thymeleaf用法 对arrayList对象pics遍历,使⽤img作为接受参数接收,使⽤iterStat作为pics下标值,通过iterStat.index得到当前所处下标值; 通过th:src="${img.path}"得到对象中图⽚路径设置图⽚显⽰图
<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样式
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论