Spring不同类型参数传参
普通类型传参
当POJO中使用简单类型属性时, 参数名称与POJO类属性名保持一致
POJO类
public class User {
private String name;
private Integer age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
Controller
@RequestMapping("/requestParam1")
public String requestParam1(String name ,String age){
System.out.println("name="+name+",age="+age);
return "page.jsp";
}
访问URL: http://localhost/requestParam1?name=itheima&age=14
**@RequestParam** 的使用