Spring boot 如何访问th:objects列表并使用th:each对其进行迭代?

Spring boot 如何访问th:objects列表并使用th:each对其进行迭代?,spring-boot,kotlin,thymeleaf,Spring Boot,Kotlin,Thymeleaf,我正在尝试访问我的ThymileAF对象列表并对其进行迭代 我尝试访问的项目类如下所示: data class Orders(val orders: List<Order>) data class Order(val orderNumber: Long, val time: String, val name: String, val zipCode: Int,

我正在尝试访问我的ThymileAF对象列表并对其进行迭代

我尝试访问的项目类如下所示:

data class Orders(val orders: List<Order>)
data class Order(val orderNumber: Long,
                 val time: String,
                 val name: String,
                 val zipCode: Int,
                 val recipientType: String?,
                 val recipientName: String?,
                 val recipientZipCode: String?,
                 val recipientCity: String?,
                 val shoppingNote: String?,
                 val id: Int,
                 val orderRows: List<OrderRow>)

data class OrderRow(val id: Int,
                    val variantTitle: String,
                    val productTitle: String,
                    val amount: Int,
                    val units: List<Unit>)

data class Unit(val code: String,
                val redeemed: Boolean?)
我使用的模板如下所示

<div class="container">
    <table class="table" th:object="${listOfOrders}">
        <thead>
        <th>#</th>
        <th>Navn</th>
        <th>ID</th>
        </thead>
        <tbody>
        <th:block th:each="order: ${listOfOrders}">
            <tr class="accordion-toggle"
                data-toggle="collapse"
                th:data-target="'#accordion_'+${order.id}">
                <td th:text="${order.orderNumber}"></td>
                <td th:text="${order.name}"></td>
                <td th:text="${order.id}"></td>
            </tr>
            <tr>
                <td></td>
                <td colspan="6">
                    <div th:id="'accordion_'+${order.id}" class="collapse in">
                        <table class="table">
                            <thead>
                            <th>#</th>
                            <th>Navn</th>
                            <th>ID</th>
                            </thead>
                            <tbody>
                            <th:block th:each="row: ${order.orderRows}">
                                <tr class="accordion-toggle"
                                    data-toggle="collapse"
                                    th:data-target="'#accordion_'+${row.id}">
                                    <td th:text="${row.amount}"></td>
                                    <td th:text="${row.productTitle}"></td>
                                    <td th:text="${row.id}"></td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td colspan="6">
                                        <div th:id="'accordion_'+${row.id}" class="collapse in">
                                            Nothing to show yet.
                                        </div>
                                    </td>
                                </tr>
                            </th:block>
                            </tbody>
                        </table>
                    </div>
                </td>
            </tr>
        </th:block>
        </tbody>
    </table>
</div>

#
纳文
身份证件
#
纳文
身份证件
还没什么可展示的。
我使用listOfOrders作为th:object的第一个块工作得很好,但是在第二次迭代中,我尝试访问订单的orderRows失败,出现了以下两条消息

org.thymeleaf.exceptions.TemplateProcessingException:异常 计算SpringEL表达式:“order.orderRows”(模板:“user”- 第50行,第39列)

org.springframework.expression.spel.SpelEvaluationException:EL1007E: 在null上找不到属性或字段“orderRows”

我目前一直在做这件事,因为一旦我可以遍历orderRows,我还需要遍历orderRows单元

我已经验证了添加到模型中的ListoOrder确实同时包含orderRows和orderRows.units

有没有关于我遗漏了什么的建议,或者关于如何让它发挥作用的建议

<div class="container">
    <table class="table" th:object="${listOfOrders}">
        <thead>
        <th>#</th>
        <th>Navn</th>
        <th>ID</th>
        </thead>
        <tbody>
        <th:block th:each="order: ${listOfOrders}">
            <tr class="accordion-toggle"
                data-toggle="collapse"
                th:data-target="'#accordion_'+${order.id}">
                <td th:text="${order.orderNumber}"></td>
                <td th:text="${order.name}"></td>
                <td th:text="${order.id}"></td>
            </tr>
            <tr>
                <td></td>
                <td colspan="6">
                    <div th:id="'accordion_'+${order.id}" class="collapse in">
                        <table class="table">
                            <thead>
                            <th>#</th>
                            <th>Navn</th>
                            <th>ID</th>
                            </thead>
                            <tbody>
                            <th:block th:each="row: ${order.orderRows}">
                                <tr class="accordion-toggle"
                                    data-toggle="collapse"
                                    th:data-target="'#accordion_'+${row.id}">
                                    <td th:text="${row.amount}"></td>
                                    <td th:text="${row.productTitle}"></td>
                                    <td th:text="${row.id}"></td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td colspan="6">
                                        <div th:id="'accordion_'+${row.id}" class="collapse in">
                                            Nothing to show yet.
                                        </div>
                                    </td>
                                </tr>
                            </th:block>
                            </tbody>
                        </table>
                    </div>
                </td>
            </tr>
        </th:block>
        </tbody>
    </table>
</div>