如何在struts中的action的execute方法()中弹出对话框(弹出 删除成功 修改成功 添

 

  如何在struts中的action的execute方法()中弹出对话框,

public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) throws IOException {
   // TODO Auto-generated method stub]
  
   // 让页面不缓存[设置JSP页面立即过期]
   response.setHeader("progma", "no-cache");
   response.setHeader("Cache-Control", "no-cache");
   response.setDateHeader("Expires", 0);

response.setContentType("tex/html;charset=utf-8");
  
   //定义session
     HttpSession adminSession = request.getSession();
     response.setContentType("text/html;charset=utf-8");
     PrintWriter out2 = response.getWriter();
   
     if(adminSession.getAttribute("userName")==null){
      out2.print("<script>alert('对不起,禁止非法访问,请先登录!');window.parent.location.href='./login.jsp';</script>");
      return null;
     }


下面这是一个实例,以修改成功为例,然后跳转到列表页面的.do请求():

    response.setContentType("text/html;charset=utf-8");
     PrintWriter outjs = response.getWriter();
     outjs.print("<script>alert('修改成功!!');window.location.href='./lyadmin.do?method=lyAdminList&page=1';</script>");
     return null;

上面的是在你点了 修改成功 弹出窗口中的确认后,在右边iframe中打开列表页面,如果想在新窗口中打开的话,加parent
     response.setContentType("text/html;charset=utf-8");
     PrintWriter outjs = response.getWriter();
     outjs.print("<script>alert('修改成功!!');window.parent.location.href ='./lyadmin.do?method=lyAdminList&page=1';</script>");

 

你可能感兴趣的:(html,jsp,struts,cache)