I upgraded to Spring 3.1.1.RELEASE, and now I'm getting an exception on the following method:
@RequestMapping(method = RequestMethod.POST, params = "_finish")
public ModelAndView doPostFinish(@PathVariable("runEnvironmentName") RunEnvironment pEnvironment, @ModelAttribute("command") JobSpecNewCommand pCommand, BindingResult pErrors)
{
...
}
Throws the following exception:
java.lang.IllegalStateException: An Errors/BindingResult argument is expected to be immediately after the model attribute argument in the controller method signature: java.lang.IllegalStateException: An Errors/BindingResult argument is expected to be immediately after the model attribute argument in the controller method signature: public org.springframework.web.servlet.ModelAndView de.wwag.infra.oocsd.projectAdmin.fe.natures.hudson.jobspecs.RunEnvJobSpecNewController.doPostFinish(de.wwag.infra.oocsd.projectAdmin.common.domain.RunEnvironment,de.wwag.infra.oocsd.projectAdmin.fe.natures.hudson.jobspecs.JobSpecNewCommand,org.springframework.validation.BindingResult) at org.springframework.web.method.annotation.ErrorsMethodArgumentResolver.resolveArgument(ErrorsMethodArgumentResolver.java:62) ...
As you can see the method signature is as expected. The BindingResult argument is declared after the model attribute.
In the same class the following method is declared:
@ModelAttribute("otherJobSpecs")
public List<JobReference> modelOtherJobSpecs(@PathVariable("runEnvironmentName") RunEnvironment pEnvironment, @ModelAttribute("command") JobSpecNewCommand pCommand)
{
...
}
When I remove the method from the class, everything works as expected.
Any ideas?
Reading the Spring bug SPR-9378, you must remove the model variable from the @ModelAttribute method:
It worked for me.
It's a bug in Spring, I reported it: SPR-9378.