知道为什么验证没有发生?我希望它能被我的@ControllerAdvice
映射选中,但控制器中的代码只是执行,因为没有进行验证。
@RequestMapping(value = "/endpoint", method = RequestMethod.GET)
public MyResponse searchSomething(@Validated
@NotNull
@Size(min=2)
@RequestParam("lastName") String lastName) { ... }
@ExceptionHandler(ConstraintViolationException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public ErrorResponse processConstraintViolationExceptionError() { ... }