Nested block not allowed

47 views Asked by At

I use spring boot and thymeleaf

<th:block th:each="claim:${claimEditor}">

<table>
    <tr>
        <td>Number of claim : </td>  <td th:text="${claim.numberOfClaim}"></td>
    </tr>

    <th:block th:unless="${#lists.isEmpty(claim.record)}">
        
        <th:block th:each="record, iterStat:${claim.record}">
        
            <tr>
                <td th:rowspan="${record.size()} th:if="${iterStat.first}">Attribute : </td>  
                <td th:text="${record}"></td>
            </tr>
        
        </th:block>
    
    </th:block>

</table>
</th:block>

I have the error

Malformed markup: Attribute "</th:block>" appears more than once in element

Seem like nested block is not allowed, is there an alternative?

1

There are 1 answers

0
Metroids On BEST ANSWER

In this specific case, you can move your th:eaches onto the table and and tr elements respectively:

<table th:each="claim:${claimEditor}">
    <tr>
        <td>Number of claim : </td>
        <td th:text="${claim.numberOfClaim}"></td>
    </tr>

    <th:block th:unless="${#lists.isEmpty(claim.record)}">
        <tr th:each="record, iterStat:${claim.record}">
            <td th:rowspan="${record.size()}" th:if="${iterStat.first}">Attribute : </td>  
            <td th:text="${record}"></td>
        </tr>
    </th:block>
</table>

Edit: You are also missing a closing double quote after th:rowspan="${record.size()}