SpringMVC中redirect跳轉后如何保存Model中的數據?


@RequestMapping(value = "delete-user", method = RequestMethod.POST)

public String deleteUser(Long[] userId, RedirectAttributes modelMap) {

  userService.deleteUser(userId);

  modelMap.addFlashAttribute("resultMsg", "刪除成功");

  return "redirect:list-user.shtml";

}

這種方式從spring3.1開始支持,原理是:

把屬性放到session中,在跳到頁面后又在session中馬上移除對象,所以在刷新一下后這個值就會丟掉。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM