1.遇到的问题:
今天开发接口,遇到请求参数固定为List<CommonConfigBean>类型的,如下。发现参数校验失效。
@RequestMapping(method = RequestMethod.POST)
public void insertCommonConfig(@RequestBody @Validated List<CommonConfigBean> list){
int result=commonConfigService.insertCommonConfig(list);
//更新缓存池
if(result>0) {
updateCache(list);
log.info("refresh the configCache");
}
}
@Getter
@Setter
@ToString
public class CommonConfigBean {
/**主键id*/
private Integer id;
/**参数名称*/
@Length(max = 30)
@NotEmpty
private String itemName;
/**参数值*/
@Length(max = 1000)
@NotEmpty
private String itemValue;
/**备注*/
@Length(max = 50)
private String memo;
}
2.解决方案一:
新建一个类,把List<SaveVideoR