form前台提交List<Object>对象以及后台处理

页面:

<form method="post" action="test.do" id="form">

  <input type="text" name="users[0].username"/>

  <input type="text" name="users[0].password"/>

 <input type="text" name="users[1].username"/>
<input type="text" name="users[2].password"/> </form>

新建一个实体类:

public class UserList{

  private List<User> users;

  public List<User> getUsers(){return users;}

  public void setUsers(List<User> users){this.users=users;}

  public UserList(){super();}

  public UserList(List<User> users){
       super();
       this.users=users;
  }

controller中接收数据:

   @RequestMapping("/insertData")
    public String insertData(UserList userList) {
      //
    
}

 

posted @ 2018-06-14 17:18  开拖拉机的蜡笔小新  阅读(1068)  评论(0编辑  收藏  举报