yeah, the same question as @PathVariable Validation in Spring 4 and Add class level validation to @Pathvariable in Spring
spring validated not work for param, throw no exception, here is my code follow by @Patrick's answer, thx for him
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
return new MethodValidationPostProcessor();
}
/**
*
* @param accountId
*/
@RequestMapping(value="/orderDetailSelByAccountId/{accountId}.json",method= {RequestMethod.POST})
@ResponseBody
@Validated
public Result<?> orderDetailSelByAccountId( @NotNull @NotBlank
@Size(min=10,max=32)@PathVariable(value="accountId") String accountId) { .... }
but when I send null accountId, there are no exception throws... am I right, are there anyother solutions?
Add the following annotation to the class worked for me.(Not to the method)
@Validated
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With