0

假设我有两个类,如下所示

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>
4

1 回答 1

-1

迭代学生集合的示例。

 <tr>
        <td>Favourite Web Frameworks :</td>
        <td><c:forEach items="${studentCollection}" var="student">
               [<c:out value="${student.id}" />]
            </c:forEach>
        </td>
    </tr>

参考这个例子。

于 2013-09-20T15:29:43.553 回答