小编典典

Spring MVC 3.1异常:模型属性参数之后应紧接一个Errors / BindingResult参数

spring-mvc

我已升级到Spring 3.1.1.RELEASE,现在在以下方法上出现异常:

@RequestMapping(method = RequestMethod.POST, params = "_finish")
public ModelAndView doPostFinish(@PathVariable("runEnvironmentName") RunEnvironment pEnvironment, @ModelAttribute("command") JobSpecNewCommand pCommand, BindingResult pErrors) 
{
...
}

引发以下异常:

java.lang.IllegalStateException:预期会出现Errors / BindingResult参数 
在控制器方法中紧随模型属性参数之后 
签名:

java.lang.IllegalStateException:预计在控制器方法签名中的模型属性参数之后紧随Errors / BindingResult参数: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)
    在org.springframework.web.method.annotation.ErrorsMethodArgumentResolver.resolveArgument(ErrorsMethodArgumentResolver.java:62)...

如您所见,方法签名是预期的。BindingResult参数在model属性之后声明。

在同一类中,声明以下方法:

@ModelAttribute("otherJobSpecs")
public List<JobReference> modelOtherJobSpecs(@PathVariable("runEnvironmentName") RunEnvironment pEnvironment, @ModelAttribute("command") JobSpecNewCommand pCommand) 
{
...
}

当我从类中删除该方法时,一切都按预期工作。

有任何想法吗?


阅读 289

收藏
2020-06-01

共1个答案

小编典典

我报告了它是Spring的错误:SPR-9378

2020-06-01