2

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?

1
  • Can you add the code of the controller method where the data is sent? Commented May 7, 2010 at 15:49

1 Answer 1

1

Try following code :

<c:forEach var="user" items="${users}">
    <tr>
            <td><c:out value="${users.age}"/></td>
    </tr>
</c:forEach>

and make sure that you have users arraylist in the request scope.. Or else use add following code:

<jsp:useBean id="users" scope="request" type="java.util.Collection" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.