1

I have a several command objects of the same type to bind, each of which represents a row from a form. How do I bind these in an annotation based controller? How do I access them on the JSP?

1 Answer 1

4

Create a form object containing these rows

public class FooList {
    private List<Foo> foos;    
    ...
}

and use it as a command object. To bind rows to form fields, use indexed paths:

<form:form modelAttribute = "fooList" ...>
    <ul>
    <c:forEach items = "${fooList.foos}" varStatus = "s">
        <li><form:input path = "foos[${s.index}].name" /></li>
    </c:forEach>
    </ul>
</form:form>
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.