Content Application Developer Manual / Version 2110
Table Of ContentsWhen errors during binding should be handled within a handler method, an optional BindingResult method parameter must be added to the handler method to be able to access any validator errors added during binding.
Note
The method parameter BindingResult
MUST follow the
validated parameter immediately!
public ModelAndView handleFormSubmit( @ModelAttribute("nameOfForm") @Valid MyForm form, BindingResult formBindingResult, ...)
BindingResult#hasErrors()
can be used to check for errors in the handler
method.
BindingResult#reject()
can be used to add errors (as a result of a business
transaction, for example) in the handler method.