<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>是否</title>
<script type="text/javascript" language="javascript">
function sure() 

  if(confirm("是否继续添加员工资料")){
<jsp:forward page="/index.jsp"/>
  }else{
 location.href="fdfaf.jsp";
  }
}
</script> </head><body onLoad="sure()">
</body>
</html>为什么不会出现确认框就直接转向 index.jsp;

解决方案 »

  1.   

    <jsp:forward page="/index.jsp"/>这句写法的问题吧,
    可以直接<括号这样写么,而且句尾没有分号然后你先把<jsp:forward page="/index.jsp"/>换成是alert("OK!")试试看能不能出确认框
      

  2.   

    能的,如果这样是可以的
    <script type="text/javascript" language="javascript">
    function sure()  
    {  
      if(confirm("是否继续添加员工资料")){
      location.href="index.jsp";
       }else{
     location.href="fdfaf.jsp";
       }
    }
    </script>  
      

  3.   

    楼主你好:
       <jsp:forward  />这个标签怎么可以在javascript标签<script></script>使用;
       你这样写本身就是一个很大的低级错误的。
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK" />
    <title>是否</title>
    <script type="text/javascript" language="javascript">
    function sure()  
    {  
      if(confirm("是否继续添加员工资料")){ location.href="reg.jsp"; 
      }else{
    location.href="index.jsp";
      }
    }
    </script>  </head><body onload="sure()">
    </body>
    </html>
      

  4.   

    <jsp:forward page="/index.jsp"/>是java代码,服务器语言,调用执行优先级是最高的。服务器加载该页面时看到这句话会立即执行。所以你错误就错在这句话了,可以替换成js调用格式location.href="index.jsp";
      

  5.   

    Employees empdg=(Employees) employeesbiz.serch(str3,str2);
    request.setAttribute("empId", empdg);

    return "success";
    谢谢各位,但我在Action的值就不能用request传给要index.jsp,reg.jsp了?
      

  6.   

    有一种写法,不知道可以不。action=“xxx.jsp”  提交到新的jsp页面,这个jsp页面写上java语句,再request。jsp页面在<% %>标签里,写上你的java代码。这也等于写一个java类