diff --git a/spring-framework-reference/src/mvc.xml b/spring-framework-reference/src/mvc.xml index 136a4fb689e..46e2a4585fc 100644 --- a/spring-framework-reference/src/mvc.xml +++ b/spring-framework-reference/src/mvc.xml @@ -949,10 +949,8 @@ public class RelativePathUriTemplateController { Handler methods that are annotated with @RequestMapping can have very flexible - signatures. They may have arguments of the following types, in - arbitrary order (except for validation results, which need to follow - right after the corresponding command object, if desired): - + signatures. Most of them can be used in arbitrary order (see below for + more details). Request or response objects (Servlet API). Choose any specific request or response type, for example @@ -1084,6 +1082,30 @@ public class RelativePathUriTemplateController { + The Errors or + BindingResult parameters have to follow + the model object that is being bound immediately as the method + signature might have more that one model object and Spring will create + a separate BindingResult instance for + each of them so the following sample won't work: + + + Invalid ordering of BindingResult and @ModelAttribute + + @RequestMapping(method = RequestMethod.POST) +public String processSubmit(@ModelAttribute("pet") Pet pet, + Model model, BindingResult result) { … } + + Note, that there is a Model + parameter in between Pet and + BindingResult. To get this working + you have to reorder the parameters as follows: + + @RequestMapping(method = RequestMethod.POST) +public String processSubmit(@ModelAttribute("pet") Pet pet, + BindingResult result, Model model) { … } + + The following return types are supported for handler methods: