首页 > 解决方案 > thymeleaf 中的嵌套迭代无法正常工作

问题描述

我正在尝试为电影院大厅建立座位选择视图。我设法从 Arraylist 中迭代对象,但 row_iterator 在第 3 行卡在 0 处,我在其中设置了 top position <i>(top: '+(row_iterator.index*20)+'px')</i>

在第 2 行和第 6 行,迭代器工作。任何帮助表示赞赏

HTML:

<th:block class="hall__row" th:each="row, row_iterator: ${theater.getRows()}">
    <div class="hall__places-row _left" th:attr="data-row=${row.getId()}" th:attrappend="style=${'top: '+(row_iterator.index*20)+'px'}"> </div>
    <div class="hall__places-item is-free" th:each="seat, seat_iterator : ${row.getSeats()}" th:attr="data-row=${row.getId()}" data-column="1" data-price-id="1" data-pos-x="1" data-pos-y="12" data-state="free" data-price="40" data-place-size="20" th:attrappend="style=${'left: '+((seat_iterator.index+1)*20)+'px;'+'top: '+(row_iterator.index*20)+'px'}">
        <div class="hall__places-chair" th:attr="data-title=${movie.getPrice()}" data-toggle="tooltip" data-placement="top"></div>
    </div>
    <div class="hall__places-row _right" th:attr="data-row=${row.getId()}" th:attrappend="style=${'top: '+(row_iterator.index*20)+'px'}"> </div>
</th:block>

标签: htmlspring-bootnestediteratorthymeleaf

解决方案


推荐阅读