我有一个'产品'的列表,我想使用html模板显示为一个行表的列表。合并th:每一个使用Thymeleaf的模板元素
HTML模板的样子:
<tr th:fragment="productTemplate">
<td th:text="${productName}">product name</td>
<td th:text="${productprice}>product price</td>
</tr>
这里是我做过什么:
<table>
<tr th:each="product : ${products}" th:substituteby="product :: productTemplate" th:with="productName=*{name}, productPrice=*{price}" />
</table>
如果我使用th:include
,会有TR嵌套到每个tr
如果我使用th:substituteby
,替补有优先th:each
我无法找到一种方法来取代我的循环项目由其他。
有人有解决方案来做到这一点?