spring-mvc binding arraylist in form

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-05-05T07:20:42Z Indexed on 2010/05/05 10:38 UTC
Read the original article Hit count: 756

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about spring-mvc

Related posts about jsp