码迷,mamicode.com
首页 > 其他好文 > 详细

thymeleaf标签 th:each的使用

时间:2014-10-27 17:04:13      阅读:1956      评论:0      收藏:0      [点我收藏+]

标签:style   io   ar   使用   sp   div   on   cti   html   

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

  <img th:src="${img.path}" style="width: 303px;height: 171px;"/>

</div>
解说:
  对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样式

 

thymeleaf标签 th:each的使用

标签:style   io   ar   使用   sp   div   on   cti   html   

原文地址:http://www.cnblogs.com/shareze/p/4054409.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!