thymeleaf 遍历使用案例

1、示例:

<div class="item"  th:if="${iterStat.index==0}" th:each="pic,iterStat:${pics}">

  <img th:src="${pic.path}" style="xxx"/>

  <p th:text="${pic.name}"></p>

</div>

2、解说:
  对arrayList对象pics遍历,使用pic作为接受参数接收,使用iterStat作为pics下标值,通过iterStat.index得到当前所处下标值;
  通过th:src="${pic.path}"得到对象中图片路径设置图片显示图

  通过th:text="${pic.name}"得到对象中图片名称

猜你喜欢

转载自www.cnblogs.com/kingsonfu/p/9840157.html
今日推荐