无法在百里香叶中传递模型属性 th:each



我正在尝试迭代一个列表并将当前迭代和另一个模型变量传递给片段,但"其他"模型变量始终为空。

<div th:each="place : ${results.placeResults}" class="col-sm-6 col-xl-4 mb-5">
<div th:replace="fragments/placecard :: placecard" th:with="place=${place},res=${results}"/>
</div> <!-- end for each-->

在片段中,${res}始终为空。

我想通了,th:replace基本上使th:with没有效果。 我更改了代码以使用th:include,事情看起来更好。

最新更新