There is a section which explains multi valued check boxes.
<input type="checkbox"
class="ads_Checkbox"
th:text="${q.questionName}"
th:value="${q.id}" name="id"/>
In the above code we are not binding the value to the field of the command object. Instead try doing this
<input type="checkbox"
class="ads_Checkbox"
th:text="${q.questionName}"
th:field="*{selectedQuestions}"
th:value="${q.id}" />
here the selectedQuestions is an array object present in the spring command object.
本文介绍了解决Thymeleaf在渲染checkbox时无法正确设置value值的方案,特别是针对Spring Command对象中数组类型的字段。通过阅读THYMELEAF官方文档,尤其是关于多值复选框的部分,找到了正确的绑定方式。
3213

被折叠的 条评论
为什么被折叠?



