假设我有两个课程,如下所示
Class Student{
private int id;
private String name;
private String address;
}
Class University{
private String id;
private String name;
private String address;
private ArrayList<Student> students;
//Getters and Setter methods
}
现在我如何将大学bean绑定到形成这样我可以捕获控制器中学生列表的数据?像这样的东西
<form:form action ="controller.htm">
//... input tags binded with university id, name and address
<form:input path = "students[0].id">
<form:input path = "students[0].name">
<form:input path = "students[0].address">
<form:input path = "students[1].id">
<form:input path = "students[1].name">
<form:input path = "students[1].address">
//... and so on
</form:form>
答案 0 :(得分:-1)
迭代学生集合的示例。
<tr>
<td>Favourite Web Frameworks :</td>
<td><c:forEach items="${studentCollection}" var="student">
[<c:out value="${student.id}" />]
</c:forEach>
</td>
</tr>
请参阅此Example.