Iterate over the list in the list and show in the table

I have a list in a list and it looks like this:

List<List<Integer>> coverage

In my controller, I give it models. In my template, I want to iterate over lists of integers in a list and show this in 1 table.

        <table class="table table-hover table-bordered">

            <tr>
                <td class="table-colspan" colspan="1" >1</td>
                <td class="table-colspan" colspan="1" >2</td>
                <td class="table-colspan" colspan="1" >3</td>
                <td class="table-colspan" colspan="1" >4</td>
                <td class="table-colspan" colspan="1" >Total</td>
                <td class="table-colspan" colspan="1" >6</td>

            </tr>
            <tr class="title-tr" th:each="list : ${coverage}">
            <tr class="title-tr" th:each="r, iterationStatus : ${list}">
                <tr th:text="${r}"></tr>
                <td th:text="${r}" ></td>
                <td th:text="${r}"></td>
                <td th:text="${r}"></td>
                <td th:text="${r}"></td>
                <td th:text="${r}"></td>
                 </tr>
            </tr>

        </table>

First, I iterate over the list to get each. List<Integer> After that, I iterate over myself List<Integer>to view integers. But each integer from List<Integer>gets its own string. So, the first integer is List<Integer>displayed 6 times.

How can i fix this?

I hope my situation is clear enough, otherwise I will give additional information. Thanks in advance.

+4
source share
1 answer

, tr tr. , :

<tr class="title-tr" th:each="list : ${coverage}">
   <td th:each="r, iterationStatus : ${list}" th:text="${r}">
   </td>
</tr>

P.S. , , : tr, th:block tr tr:

   <th:block th:each="list : ${coverage}"> 
       <tr th:each="r : ${list}"> ... </tr>
   </th:block>
+4

Source: https://habr.com/ru/post/1690678/


All Articles