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

页面:

<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) {
      //
    
}

 

相关文章:

  • 2021-12-21
  • 2022-12-23
  • 2021-11-27
  • 2021-09-22
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案
粤ICP备22038628号Powered By WordPress