重定向执行完成后,不能跳到指定页面进行刷新显示吗?能执行,jsp页面没有立即显示添加的内容
resp.sendRedirect(req.getServletContext().getContextPath()+"/updatedetail");
```java
@WebServlet("/updatedetail")
public class updatedetail extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doPost(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
HttpSession httpSession=req.getSession();
Integer food_id=(Integer) httpSession.getAttribute("fdid");
System.out.println("tainanl"+food_id);
pinglundao pldao=new pinglundao();
List<pinglun> pList=pldao.findbyid(food_id);
System.out.println("msg"+pList);
for (pinglun pinglun : pList) {
//通过评论id查询所有的评论回复信息
List<reply> rList=pldao.findBymsgid(pinglun.getMsg_id());
pinglun.setReplies(rList);
}
req.getSession().setAttribute("msgs", pList);
req.getRequestDispatcher("detail.jsp").forward(req, resp);
}
}
```