defaultValue = 方法入参默认值
required = 是否必须包含该参数(false 不包含该参数)
value = 请求参数名(等价于name)
// dataTypeBase?age=12&avg=50
@RequestMapping(value = "dataTypeBase", method = RequestMethod.GET)
public ModelAndView dataTypeBase(
@RequestParam(defaultValue="18",name="a") int age,
@RequestParam(defaultValue="50",name="b") double avg
) {
System.out.println("age:"+age);
System.out.println("avg:"+avg);
return new ModelAndView("index");
}
// dataTypeRef?age=12&avg=50
@RequestMapping(value = "dataTypeRef", method = RequestMethod.GET)
public ModelAndView dataTypeRef(
@RequestParam(required=true) Integer age,
@RequestParam(required=true) Double avg
) {
System.out.println("age:"+age);
System.out.println("avg:"+avg);
return new ModelAndView("index");
}