我将方法SubmitBranchInsert的返回类型更改为String,如下所示
@RequestMapping(value="/branchsubmitinsert.travel", method=RequestMethod.POST)public String submitBranchInsert(ModelMap model,@ModelAttribute BranchModel branchModel){ //ModelAndView modelAndView = new ModelAndView("/branch/branchinsert"); //modelAndView.addObject("branch",branchModel); //return modelAndView; model.addAttribute("branch", branchModel); return "/branch/branchinsert";}
现在可以了,但是为什么我不能在这里使用ModelAndView代替String中的Model,这可能是我对Spring
MVC专家们的愚蠢的声音。我只想知道什么时候应该在字符串中使用ModelAndView而不是Model?我不想单独问这个问题,这就是为什么我要用我的答案本身来问这个问题。有人可以帮助我吗?
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)