@RequestMapping(value = "delReply")
@ResponseBody
public String delReply(@Param("replyid") Integer replyid, HttpSession session, RedirectAttributes attr) {
Integer userid = (Integer) session.getAttribute("userid");
msgReplyService.delReply(replyid);
attr.addAttribute("userid",userid);
System.out.println("删回复表");
return "redirect:message";
}
重定向失效,页面显示的是redirect:message,并不是转到message方法。
解决方案:
@RequestMapping(value = "delReply")
public String delReply(@Param("replyid") Integer replyid, HttpSession session, RedirectAttributes attr) {
Integer userid = (Integer) session.getAttribute("userid");
msgReplyService.delReply(replyid);
attr.addAttribute("userid",userid);
System.out.println("删回复表");
return "redirect:message";
}
其实是我把上个ajax方法复制过来修改了一下,但是没删 @ResponseBody。所以才会重定向失效,ajax需要用到 @ResponseBody,但是普通方法有重定向就别加上这句话了。