Spring Boot application with Thymeleaf views gives me parsing error when I try to use index variable inside array like this:
<tr th:each="cdItem, stat : *{commonDataItems}">
<td th:text=${stat.index}>Index</td>
<td> <input type="text" th:field=*{commonDataItems[__${stat.index}__].value>Value</td>
</tr>
This <td th:text=${stat.index}>Index</td> line is for testing purposes and it gives the right index value, but next line <td> <input type="text" th:field=*{commonDataItems[__${stat.index}__].value>Value</td> gives parsing error.
Error message is:
org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "*{commonDataItems[__${stat.index}__].value" (common)
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:238) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:79) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
Any ideas what is wrong?
th:field="*{commonDataItems[__${stat.index}__].value"