首页 > 其他 > 详细

zbb20171221 thymeleaf th:each

时间:2017-12-21 15:39:41      阅读:227      评论:0      收藏:0      [点我收藏+]

th:each属性用于迭代循环,语法:th:each="obj,iterStat:${objList}"

迭代对象可以是java.util.List,java.util.Map,数组等;

iterStat称作状态变量,属性有:
    index:当前迭代对象的index(从0开始计算)
    count: 当前迭代对象的index(从1开始计算)
    size:被迭代对象的大小
    current:当前迭代变量
    even/odd:布尔值,当前循环是否是偶数/奇数(从0开始计算)
    first:布尔值,当前循环是否是第一个
    last:布尔值,当前循环是否是最后一个

 

<table class="table table-bordered">
                                    <tr>
                                        <th style="width: 10px">序号</th>
                                        <th>名称</th>
                                        <th>涨幅(图)</th>
                                        <th style="width: 40px">涨幅</th>
                                    </tr>
                                    <tr th:each="obj ,iterStat: ${appkindList}">
                                        
                                        
                                        <td th:text="${iterStat.count}">-</td>
                                        <td><a th:text="${obj.name}" class="btn btn-link  btn-xs"
                                            data-toggle="modal" href="#"
                                            th:attr="data-target=${‘#‘+obj.text+‘_MODEL‘}">-</a></td>
                                        <td>
                                            <div class="progress xs">
                                                <div class="progress-bar progress-bar-danger"
                                                    th:attr="style=${‘width:‘+obj.value*100+‘%‘}"></div>
                                            </div>
                                        </td>
                                        <td><span
                                            th:text="${#numbers.formatDecimal(obj.value*100,0,2)+‘%‘}"
                                            class="badge bg-blue">-</span></td>
                                    </tr>

                                </table>

 

zbb20171221 thymeleaf th:each

原文:http://www.cnblogs.com/super-admin/p/8080643.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!