解决此问题的方法非常简单,所有工作已在 CustomCollectionEditor中
完成。当绑定诸如上述的复杂数据类型时,这一点很重要。可能还有其他方法可以做到这一点,但是我发现这是一种非常干净和简单的方法。
return语句非常重要,因为它绑定到视图中元素的item属性。 CustomCollectionEditor 返回对象列表( 受害者 )使用
DAO 从数据库中获取对象。这很重要,因为该帖子仅发送选择值,而不发送标签,因此我们重建列表并重新发送到视图。
我省略的部分是将List Object从控制器传递回视图。
控制者
@RequestMapping(value="save.htm", method = RequestMethod.POST) public ModelAndView handleSave(@Valid @ModelAttribute Crime crime, BindingResult result, ModelMap m, Model model) throws Exception { if(result.hasErrors()){model.addAttribute("victimList",crime.getVictims()); return new ModelAndView("*Your View*");...............


