mardi 23 février 2021

Spring MVC Form Checkbox vs Checkboxes

I am facing strange problem with form:checkbox attribute in my Spring MVC form. I am trying to display and edit checkbox values and I don't understand why "form:checkboxes" is working and "form:checkbox" is not.

Here is my code:

form:checkboxes
<form:checkboxes path="packing" items="${packList}" itemValue="id" itemLabel="name" />
<br /><br />
form:checkbox
<c:forEach items="${packList}" var="pack" varStatus="packStatus">
   <form:checkbox path="packing"  value="${pack.id}" label="${pack.name}" />
</c:forEach>

First checkbox is working, the second one in forEach is not checked and I do not why. The result page screenshot: Result page

Am I doing anything wrong? Unfortunately I have to use checkbox with forEach to add more elements.

I am using Spring version 5.1.9.RELEASE

Any advice is appreciated!




Aucun commentaire:

Enregistrer un commentaire