I have a several command objects of the same type to bind, each of which represents a row from a form. How do I 开发者_StackOverflow社区bind these in an annotation based controller? How do I access them on the JSP?
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>
精彩评论