admin管理员组文章数量:1430550
folks...
Can I do something like this using Thymeleaf?
<tr th:each="row : ${list}">
<td th:each="field : ${arrayFieldName}" scope="row">
<span th:text="|${row.${field[0]}}|"></span>
</td>
</tr>
I can use:
<span th:text="|${row.nameOfMyField1}|"></span>
<span th:text="|${row.nameOfMyField2}|"></span>
that works fine... but in this case I need to perform the th:each for every field name that I have in ${arrayFieldName}.
How can I do this?
folks...
Can I do something like this using Thymeleaf?
<tr th:each="row : ${list}">
<td th:each="field : ${arrayFieldName}" scope="row">
<span th:text="|${row.${field[0]}}|"></span>
</td>
</tr>
I can use:
<span th:text="|${row.nameOfMyField1}|"></span>
<span th:text="|${row.nameOfMyField2}|"></span>
that works fine... but in this case I need to perform the th:each for every field name that I have in ${arrayFieldName}.
How can I do this?
Share Improve this question asked Nov 19, 2024 at 13:27 gaplergapler 91 bronze badge1 Answer
Reset to default 0Yes, this is called preprocessing in Thymeleaf. It should look like this:
<tr th:each="row : ${list}">
<td th:each="field : ${arrayFieldName}" scope="row">
<span th:text="|${row.__${field}__}|"></span>
</td>
</tr>
本文标签: Thymeleaf and macro substitutionStack Overflow
版权声明:本文标题:Thymeleaf and macro substitution - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745559085a2663363.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论