我已经定义了一个 @ModelAttribute("mymodel")
@ModelAttribute("mymodel")
MyModel mymodel() {
MyModel mymodel = new MyModel();
return mymodel;
}
@RequestMapping(value = "/save", method = RequestMethod.POST)
public final void save(@ModelAttribute("mymodel") MyModel mymodel,
final BindingResult binding,
final HttpServletRequest request,
final ModelMap modelMap) throws Exception {
modelService.save(mymodel);
// try to reset the model --> doesn't work!!!
myModel = new MyModel();
}
问题是,即使我在 save 方法中重置了模型,但如果我在保存操作后重新加载页面并再次保存,模型会包含之前的所有值myModel
。
处理后如何重置?