spring mvc 接受物件陣列
//html程式碼
<form action="http://192.168.1.153:8080/lhzsmm/mobile/wx/test">
<input type="text" name="students[0].name" value="xs2"/><input type="text" name="students[0].age" value="11"><br/><input type="text" name="students[1].name" value="xs3"/><input type="text" name="students[1].age" value="12"><br/>
<input type="submit" value="提交" />
</form>
//後臺程式碼
@RequestMapping("test")
@ResponseBody
public WXResponseObjectModel<Student> test(StudentContent students){
WXResponseObjectModel<Student> response = new WXResponseObjectModel<>();
response.setDatas(students.getStudents());
return response;
}
public class StudentContent {
private List<Student> students;
public List<Student> getStudents() {
return students;
}
public void setStudents(List<Student> students) {
this.students = students;
}
}