字段必须和传参时一致,否则为null,
使用AIT+INS可以快速生成,SET GET方法
public class User { //字段必须和传参时一致,否则为null private String user; private String password; public String getUser() { return user; } public void setUser(String user) { this.user = user; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "User{" + "user='" + user + '\'' + ", password='" + password + '\'' + '}'; } }
复杂嵌套参数
两个类 现将两个类合并对象,返回前端,把Update封装到User
User
public class User { private String user; private String password; private Update up; public Update getUp() { return up; } public void setUp(Update up) { this.up = up; } public String getUser() { return user; } public void setUser(String user) { this.user = user; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "User{" + "user='" + user + '\'' + ", password='" + password + '\'' + ", up=" + up + '}'; } }
Update
public class Update { private String time; private int num; public String getTime() { return time; } public void setTime(String time) { this.time = time; } public int getNum() { return num; } public void setNum(int num) { this.num = num; } @Override public String toString() { return "Update{" + "time='" + time + '\'' + ", num=" + num + '}'; } }
前端给Update time 和 num 传值
http://127.0.0.1:8080/login?up.time=123