我定义了一个@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的所有值.
处理后如何重置?
最佳答案
原文链接:https://www.f2er.com/spring/531729.html