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