@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中馬上移除對象,所以在刷新一下后這個值就會丟掉。