Request
Spring Form 在调用中填充时无法成功提交 [给出绑定问题] loadForm
,但在setupFormObject
使用@ModelAttribute
注释标记填充方法时工作正常。我可以在 github 中提供一个简单的示例来测试是否需要:)
我花了几天时间搜索甚至使用 AutoPopulatingList 但无济于事
下面的例子
@ModelAttribute("showForm")
public ShowForm setupFormObject() {
//Instantiate showForm with data
return showForm;
}
@RequestMapping(method = RequestMethod.GET)
public ModelAndView loadForm(@RequestParam("id") String id, HttpSession session) {
ModelAndView modelAndView = new ModelAndView(nextPage);
//Instantiate showForm with data
//modelAndView.addObject("showForm", showForm);
return modelAndView;
}
@RequestMapping(method = RequestMethod.POST)
public String post(@ModelAttribute("showForm") ShowForm showForm, BindingResult result, final RedirectAttributes redirectAttrs) {
//I see changed data here in showForm when populated using @setupFormObject
//See an exception in JSP with binding error if populated in loadForm
return "";
}
非常感谢您的帮助
谢谢