没报错信息,而是直接转到error.jsp这个页面去了。
数据库中没有添加的数据!
请大家帮忙!谢谢了!

解决方案 »

  1.   

    把你这条语句中的单引号去了再试试.
    values('"+xuehao+"','"+name+"','"+sex+"',"+i+",'"+jiguan+"','"+department+"')";报错肯定是有的,不知你用的是什么服务器?tomcat的话在tomcat的启动后弹出的命令提示符界面有报错.或者在error.jsp中加上
    <%
    PrintWriter writer=response.getWriter();
    exception.printStackTrace(writer);
    %>
    也可以把错误信息在error.jsp页面打印出来.
      

  2.   

    我用的是tomcat5.0
    出错就是这么怪。
    这次调用这个jsp页面时,IE竟显示完毕。
    地址栏中显示:http://localhost:8080/ch8/query_1.jsp
    就再也没有下文了。
    我在error.jsp中加上  
     <%  
    PrintWriter  writer=response.getWriter();  
    exception.printStackTrace(writer);  
    %  >  
    这句话,但就没调到error.jsp
    大家帮下忙了,朋友们加我QQ:9744772
    我把整个JSP页面传给你,帮我看看好吗
      

  3.   

    在catch程序块的第一句位置增加下面的代码,看看出错信息
    e.printStackTrace(System.err);
      

  4.   

    chylwk(沧海一浪) 
    按你的方法作了
    还是直接跳到error.jsp页面去了
      

  5.   

    晕,你这是干吗?     catch(Exception e)
        {
    response.sendRedirect("error.jsp");
    System.out.println("ddddddddddd"+e);
        }
    }catch这儿应该打印出错误信息,或者重新抛出错误.
    在页面顶部定义errorPage=error.jsp,
    出错就会自动跳到error.jsp,把错误信息显示出来.
    你一sendRedirect就把所有错误信息都丢了,当然没显示.
    我的
    QQ 116551248
    Email [email protected]
      

  6.   

    把error也去掉,把tomcat下work文件夹删除 再看看
      

  7.   

    是会跳到error.jsp页面去的,我是让你在跳过去之前看出错信息,只有这样才能找到错误。你把后台的出错信息,给点出来看看
      

  8.   


         catch(Exception e)
        {
    response.sendRedirect("error.jsp");
    System.out.println("ddddddddddd"+e);
        }
        改成:
        catch(Exception e)
        {
         request.setAttribute("error", e.toString());
         response.sendRedirect("error.jsp");
        }
        在error.jsp里面加上这么一句话
        error.jsp:
        <%
         String error = (String)request.getAttribute("error");
         out.println("<p align='center'>错误信息</p>");
         out.println(error)
        %>
      

  9.   

    newste(旭林) 你好,我按你的意思改了,在error.jsp中,输出的错误信息是:
    错误信息null 我检查了一下我在表单中该输入的都输了,没有拉下哪个
    况且我在query_1.jsp,有if(request.getParameter("xuehao")  !=  null) 这个,不会才有错呀。
      

  10.   

    判断空一般有三种情况
    String xuehao=request.getParameter("xuehao") ;if(xuehao!= null){
    ...
    }if("".equals(uehao)){
    ...
    }if("null".equals(uehao)){
    ...
    }
      

  11.   

    我估计是你取年龄的时候没有取道值报的异常
    你在age=(String)request.getParameter("age");后面加上这句看看
    out.println("<script language="javascript">");
    out.println("alert('"+ age +"')");
    out.println("</script>");
    看看是不是显示null;
      

  12.   

    newste(旭林) 你好!我按着你的意思在后面加了,但报错:
    C:\Tomcat 5.0\work\Catalina\localhost\ch8\org\apache\jsp\query_005f1_jsp.java:68: ')' expected
      out.println("<script language="JavaScript">");
                                     ^
    1 error
    我怎么也没找到哪少了这么一个“)”。
    你为什么认为会是年龄取空了?谢谢你的大力帮助!
    真的很感谢你!!!
      

  13.   

    catch(Exception e)
        {
    response.sendRedirect("error.jsp");
    System.out.println("ddddddddddd"+e);
        }
    改为:
    catch(Exception e)
        {
    e.printStackTrace();
        }再在tomcat后台看看是什么错误,错误在哪里?(运行tomcat安装的目录下的bin文件夹里的startup.bat)
      

  14.   

    out.println("<script language="JavaScript">");
    改为
    out.println("<script language='JavaScript'>");
      

  15.   

    jyy7751(wish i could fly):
     out.println(  "  <script  language=  "JavaScript  "  >  ");  
    改为  
    out.println(  "  <script  language='JavaScript'  >  ");  
    你说的这个我都注释掉了。
    况且按你的意思我加上了还是老样子
      

  16.   

    我估计是下边一句话的错误:
    String sql="insert into Student(Xuehao,Name,Sex,Age,Jiguan,Dept)  values('"+xuehao+"','"+name+"','"+sex+"',"+i+",'"+jiguan+"','"+department+"')";
      stmt.executeUpdate(sql);  //  error!将函数环成stmt.execute(sql)!
    stmt.executeUpdate(sql)只是用在数据更新时!
      

  17.   

      String sql="insert into Student(Xuehao,Name,Sex,Age,Jiguan,Dept)  values('"+xuehao+"','"+name+"','"+sex+"',"+i+",'"+jiguan+"','"+department+"')";
      stmt.executeUpdate(sql);
    有你这么写插入的吗
    用PrepareStatement设参数写插入才是常用方法
      

  18.   

    catch语句写为
    catch(Exception e)
        {
         System.out.println(e);
         response.sendRedirect("error.jsp");
        }
    看看,直接打印到控制台;stmt.executeUpdate(sql);
    executeUpdate应该有个返回值吧。
      

  19.   

    liwenchao()
    你说的那个方法我用了,不行
    这个在JDBC中是必须要有的语句
    至于zzxhunter(宝蓝)说的,那个返回值是有,但也可以不用的这个问题还是存在!
      

  20.   

    给你一段我写的注册用户的代码给你吧。本来想调试一下你的程序的,但懒的动。
    try{
    ResultSet  rs=null;
    String sql="select * from users where USERNAME='"+User_Name+"'";
    rs=sqlbean.executeQuery(sql);
    rs.last();
    if (rs.getRow()>0)
    {
       response.sendRedirect("err.jsp?id=3");//判断是否有相同的记录
    }
    else
    {
    sql="insert into users(USERNAME,USERPASS)";
    sql=sql+" values('"+User_Name+"','"+User_Password+"')";
    try{
    sqlbean.executeInsert(sql);
    }catch(Exception e){
    out.println(e.getMessage());
    }
    session.putValue("UserName",User_Name);
    out.println(session.getValue("UserName"));
    out.println("<font size=2 color=blue>谢谢您的注册,正在处理您的用户信息,稍后会自动登陆...</font><meta http-equiv='refresh' content='2;url=index.jsp'>");
    }
    }catch(Exception ex)
    {
           String errMsg=ex.getMessage();
           response.sendRedirect("error.jsp");
    }