spring-mvc binding arraylist in form
- by Mike
In my controller I added an ArrayList to my model with the attribute name "users".
Now I looked around and this is the method I found (including a question here):
<form:form action="../user/edit" method="post" modelAttribute="users">
<table>
<c:forEach var="user" items="${users}" varStatus="counter">
<tr>
<td>
<form:input path="users[${counter.index}].age"/>
</td>
<td><button type="submit" name="updateId" id="Update" value="${user.id}">Update</button></td>
</tr>
</c:forEach>
</table>
</form:form>
But when I load the JSP page I get:
.springframework.beans.NotReadablePropertyException:
Invalid property 'projects[0]' of bean
class [java.util.ArrayList]: Bean
property 'users[0]' is not readable or
has an invalid getter method: Does the
return type of the getter match the
parameter type of the setter?
So apparantely this isn't the way to go, but in that case how do I bind an arraylist so I can edit the values?