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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM