Form表单如何传递List数组对象到后台的解决办法(转)

举例说明:

 【后台有一个对象 User    一个PhotoDo对象】,结构如下:

 public class User{

 private String username;

  private List<PhotoDo> photo;

  ..get ....set.....

 }

public class PhotoDo{

 private String id;

 private String name;

  ...get...set...

}

【Controller中接受方法 getUser】

@reqeustMapping("/getUser")

public void getUser(User user){

...实现方法...

}

【前台Form这么写:】

<form>

     <input type="text" name="username" aciton="..">

     <input type="text" name="photo[0].id">

     <input type="text" name="photo[0].name">

     <input type="text" name="photo[1].id">

     <input type="text" name="photo[1].name">

     <input type="text" name="photo[2].id">

     <input type="text" name="photo[2].name">

</form>

 

========================================分割线

 

posted @ 2016-10-22 15:08  涤新云  阅读(32199)  评论(0编辑  收藏  举报