我想打开警报窗口

时间:2014-06-22 16:57:45

标签: javascript spring jsp

我想在调用delete方法之前确认框。 并打开警报窗口如何修改以下来源?

jsp页面(删除框中单击)==>删除方法==>日期基础==> JSP(onload)

=============================================== ==================

@RequestMapping(value="delete.do")
    public String delete(HttpServletRequest request, HttpServletResponse response, ModelMap modelmap) throws Exception{
       String url = "";
       try{
          int idx = Integer.parseInt(request.getParameter("idx")); 
          int commentCnt = boardService.delCheck(idx);
          if(commentCnt == 0){
              boardService.delete(idx);
              url = "redirect:board_list.do";
          }else{
              modelmap.addAttribute("errCode", 1);
              url = "redirect:content.do?idx="+idx;
          }
       }catch(Exception e){
           e.printStackTrace();
       }
       return url;
   }



   JSP PAGE
        <script type="text/javascript">
            function deleteCheck(){
                var errCode = ${errCode};
                if(errCode != null || errCode != "")
                {
                    alert("alert");
                }
            }
        </script>

<body onload="deleteCheck()">

<body>

1 个答案:

答案 0 :(得分:0)

function deleteCheck(){
   var errCode = ${errCode};
      if(errCode != null || errCode != "")
       {
          var choice = confirm("are you sure you want to delete");
          if(choice){
            //proceed with deletion
          }
       }
   }