String id=rs.getString("id").trim();

解决方案 »

  1.   

    我的id可是int类型,另外第二个地方应该如何写?
      

  2.   

    定义放在开头去。
    int id = 0;在第一个地方:
    id = rs.getInt("id");第二个地方:<%=id%>
      

  3.   

    1.  int id=rs.getInt("id");
    2.  response.sendRedirect("stuselect.jsp?tid=id")
    or
    <jsp:forward page="stuselect.jsp?tid=<%=id%>">
      

  4.   

    ????在此处添加得到id字段值的语句。
    int id=rs.getInt("id");
             response.sendRedirect("stuselect.jsp????在此处添加传递参数的语句。");  
    stuselect.jsp?id=id
    取String id=rs.getString("id").trim();
    至于int 或Sting的转化,还用说吗?
      

  5.   

    rs.getInt啊
    stuselect.jsp&参数名=参数值
    注意这行可能会有空指针异常
    request.getParameter("name").trim(),
    strName =  dsfdsxfggjf
      

  6.   

    谢谢各位:
    我改为如下代码后报错:
    <%@  page  contentType="text/html;charset=ISO8859_1"%>
    <%@ page language="java"%>
    <%@ page import="java.*"%>
    <jsp:useBean id="workM" scope="page" class="online.onlineconn1" />
    <jsp:useBean id="workc" scope="page" class="online.ISOtoGb2312" />
    <%
    String name1=request.getParameter("name").trim(),
       key1=request.getParameter("key").trim(),
               strSQL;
    strSQL="select id,name,mkey from student where name='"+name1+"' and mkey='"+key1+"'";
    try{
          workM.executeQuery(strSQL);
      if(!workM.rs.next()){
                          response.sendRedirect("stuloginerror.htm");
                     }
         else{ 
         int stuid=0;
     stuid=workM.rs.getInt(id);
             response.sendRedirect("stuselect.jsp?id=stuid");  
     workM.disconnectToDB();
              }
        }
        catch(Exception ex){
         out.print(ex.getMessage());      
        }
    %>报错内容为:
    Generated servlet error:
        [javac] Since fork is true, ignoring compiler setting.
        [javac] Compiling 1 source file
        [javac] Since fork is true, ignoring compiler setting.
        [javac] D:\Tomcat 4\work\Standalone\localhost\test\online\stuloginform_jsp.java:87: cannot resolve symbol
        [javac] symbol  : variable id 
        [javac] location: class org.apache.jsp.stuloginform_jsp
        [javac]   stuid=workM.rs.getInt(id);
        [javac]                                                ^
        [javac] 1 error我确实在.jsp页面中没有定义id,可是id是数据中的字段名啊,也必须定义在.jsp页面吗?
      

  7.   

    妈的,IE刚才不能删除了
    strName = request.getParameter("name");
    if(null != strName)
       strName = strName.trim();
      

  8.   

    <%
    String name1=request.getParameter("name").trim(),
       key1=request.getParameter("key").trim(),
               strSQL;
    strSQL="select id,name,mkey from student where name='"+name1+"' and mkey='"+key1+"'";
    int id=0;//you should add this now 
    try{
          workM.executeQuery(strSQL);
      if(!workM.rs.next()){
                          response.sendRedirect("stuloginerror.htm");
                     }
         else{ 
         int stuid=0;
     stuid=workM.rs.getInt("id"); //add ""
             response.sendRedirect("stuselect.jsp?id=stuid");  //this id not defined
     workM.disconnectToDB();
              }
        }
        catch(Exception ex){
         out.print(ex.getMessage());      
        }
    %>
      

  9.   

    stuid=workM.rs.getInt(id);ft..........别人的回复你可要看清楚呀。都是有加引号的。
      

  10.   

    我改为如下代码后
    response.sendRedirect("stuselect.jsp?id=stuid");  
    得到的地址是:
    http://test.snow.com:8080/test/online/stuselect.jsp?id=stuid
    似乎stuselect.jsp?id=stuid没有起到传递参数的作用这样写不对吧?
      

  11.   

    成功了改为response.sendRedirect("stuselect.jsp?id="+stuid+"");  后成功了,谢谢各位!
      

  12.   

    可是参数传递之后需要转换变量类型:字符串类型如何转换为int类型啊?
      

  13.   

    response.sendRedirect("stuselect.jsp?id='stuid'");
      

  14.   

    --可是参数传递之后需要转换变量类型:字符串类型如何转换为int类型啊?String str = request.getParameter("id").trim(); 
    int temp = Integer.parseInt(str);