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?
@Validatedshould go as class level annotation according to the links you provide in the question@PathVariableat the moment.