servlet里面用script弹框为什么不显示那
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws
ServletException,
IOException {
response.setContentType("gbk");
PrintWriter out = response.getWriter();
int userId=Integer.parseInt(request.getParameter("userId"));
UserBiz userBiz=new UserBizImpl();
int isDel=0;
try {
isDel = userBiz.deleteUserById(userId);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(isDel>0){
out.print("<script>alert('删除成功');</script>");
response.sendRedirect("adminServlet");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doGet(request, response);
}
打断点是走if的。弹框写的应该没有问题吧?那位大哥帮看看。
------解决方案--------------------if(isDel>0){
out.print("<script language='javascript'>alert('删除成功!');window.location.href='adminServlet';</script>");
}