我正在遍历想要作为表单的数组。目前,我的HTML如下所示,但是在*{...}
参数中,出现以下错误:
Error:
java.lang.NumberFormatException: For input string: "${itrStat.index}"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.8.0_191]
HTML:
<form th:action="@{/admin/user/toggleranks}" th:object="${rankList}"
method="post">
<th:block th:each="rank,itrStat : ${rankList.getList()}" th:class="${itrStat.even}? 'even_css_class':'odd_css_class'">
<span th:text="${rank.getRank().getAuthority()}+': '+${rank.isOwnsRank()}"></span>
<input type="checkbox" th:field="*{list[${itrStat.index}].ownsRank}"/>
<br>
</th:block>
<input type="submit" class="btn btn-success" value="Save changes"/>
</form>
答案 0 :(得分:0)
您可以通过使用双下划线来强制Thymeleaf评估itrStat.index
:
th:field="*{list[__${itrStat.index}__]. ownsRank}"