@RequestParam注解有两个属性:
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RequestParam {
String value() default "";
boolean required() default true;
String defaultValue() default ValueConstants.DEFAULT_NONE;
}
value() 对传入参数指定名称例如ecif
required() @RequestParam配置的传入参数是否一定要传
required=false表示可以不传,默认给参数赋值为null注意(参数为基本的数据类型int时不能使用 因为null不能赋值给int )
required=true 就是必须要有传入参数
value与required配合使用如没有配置任何信息为默认值 必须输入对应参数名
value =“” ,required ="true"
例如:@RequestParam String investmentStatus,必须输入investmentStatus
@RequestParam(value = "investId", required = true) String investId,类似上一个但是有区别
当 value =“ecif” ,required ="fasle"
例如:
@RequestParam(value="ecif",required = false) String ecifId,
参数可以不输入ecif 此时ecifId为null注意(参数为基本的数据类型int时不能使用 因为null不能赋值给int )