Controller中的业务方法的POJO参数的属性名与请求参数的name一致,参数值会自动映射匹配。
public class User {
private String username;
private int age;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return "User{" +
"username='" + username + '\'' +
", age=" + age +
'}';
}
}
@RequestMapping(value="/quick12")
@ResponseBody
public void save12(User user) throws IOException {
System.out.println(user);
}