@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 { ... ... }