I have next spring rest controller for handle my exception:
@ExceptionHandler(ConstraintViolationException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
pub
Try to reproduce next steps:
@Bean public MethodValidationPostProcessor methodValidationPostProcessor() { return new MethodValidationPostProcessor(); }
mark your Controller with @Validated
Mark your paramater in Controller's method with
@Pattern(regexp = "\\d+") @RequestParam String param
If you want to use that Entity. Do something like
@Valid @RequestBody Device device
in your method. And you can skip all previous steps.