Servlet中response.sendRedirect前弹窗问题解决方法

   out.println("<script>");
   out.println("alert('修改用户数据成功!');");
   out.println("</script>");
   response.sendRedirect("/bookshop/manager/manager_doUserList");

如上所示的Servlet代码中,预期结果应该是弹出弹窗后跳转到指定页面,但是实际结果却是只跳转到指定页面而不弹出弹窗,其原因不再赘述,感兴趣的可以去网上搜。
解决方法

   out.println("<script>");
   out.println("alert('修改用户数据成功!');");
   out.println("location.href='/bookshop/manager/manager_doUserList'");//跳转到用户列表页面
   out.println("</script>");

猜你喜欢

转载自blog.csdn.net/qq_43222869/article/details/104009894
今日推荐