What configuration is needed to use annotations from javax.validation.constraints like @Size, @NotNull, etc.? Here\'s my code:
For JSR-303 bean validation to work in Spring, you need several things:
validation-api-1.0.0.GA.jar (looks like you already have that)hibernate-validator-4.1.0.Final.jar@Valid, and then include a BindingResult in the method signature to capture errors. Example:
@RequestMapping("handler.do")
public String myHandler(@Valid @ModelAttribute("form") SomeFormBean myForm, BindingResult result, Model model) {
if(result.hasErrors()) {
...your error handling...
} else {
...your non-error handling....
}
}