@RequestParam,参数是否必须传的问题
一、源码展示
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RequestParam {
@AliasFor("name")
String value() default "";
@AliasFor("value")
String name() default "";
boolean required() default true;
String defaultValue() default ValueConstants.DEFAULT_NONE;
}
这是示例代码
@GetMapping("/findById")
public ResultBean byid(@RequestParam(defaultValue = "1",required = false,/*value = "ss",*/name = "ls") Integer id){
List<Customers> all = customersService.findById(id);
return ResultBean.ok(all);
}