Spring MVC BindingResult异常

@RequestMapping(value = "/adCrowdEdit.s", method = RequestMethod.POST)
public String adCrowdEdit(Model model, HttpServletRequest request, HttpServletResponse response,
@ModelAttribute("command") Adcrowd command, @RequestParam(value="adTagString") String adTagString, BindingResult result) throws Exception {
    ... ...
}

以上代码会抛出异常:Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature

原因分析以及解决办法:BindingResult的对象紧跟在@ModelAttribute声明的对象后面,这样Spring MVC的管理控制程序才能正确的完成绑定。

修改办法如下,红色字体标出: 萌萌的IT人,IT人的乐园

@RequestMapping(value = "/adCrowdEdit.s", method = RequestMethod.POST)
public String adCrowdEdit(Model model, HttpServletRequest request, HttpServletResponse response,
@ModelAttribute("command") Adcrowd command, BindingResult result, @RequestParam(value="adTagString") String adTagString) throws Exception {
    ... ...
}

 

posted @ 2012-10-25 15:03  yanghuahui  阅读(6630)  评论(0编辑  收藏  举报