controller的方法里,用@Validated标记需要验证的参数,并且最后面要有BindingResult bindingResult参数,才能生效

public CommonResult<Integer> create(@RequestBody @Validated ProdParam prodParam, BindingResult bindingResult) {
// ...
}

评论
载入中...