<%
   request.setCharacterEncoding("UTF-8");
   String block=(String)request.getParameter("block");
   String userid=(String)request.getParameter("userid");  
    int flag=0;
  if(block!=null&&userid!=null)
  {
     
    Context   ctx; 
    Object   obj;
    javax.sql.DataSource   ds;
    Connection   conn;
try{   Context   initCtx   =   new   InitialContext();   
ctx   =   (Context)   initCtx.lookup("java:comp/env"); 
        
     obj =   (Object)   ctx.lookup("jdbc/whcgdb");   
          
  
     ds=   (javax.sql.DataSource)obj;   
     conn =   ds.getConnection();
           }catch(Exception   e){   e.printStackTrace();  
          throw   new   SQLException("cannot   get   Connection   pool.");   }  
          
    try
    {
    Statement stmt=conn.createStatement();
    String sql="select dbo.操作员.操作员帐号 from dbo.操作员 where dbo.操作员.所属城区号 in (select dbo.城区码.城区号 from dbo.城区码 where dbo.城区码.城区名称='"+block+"')";
    ResultSet rs=stmt.executeQuery(sql);
    String list[]=new String[100];
    int i=0;
   
    while(rs.next())
    {
      list[i]=rs.getString("操作员帐号");
      
    
     i++;
    } 
         
   for(int j=0;j<i;j++)
    {
       String id=list[j];
//if(id.trim().equals(userid))
       if(id.equals(userid))      {      
        flag=1;
        
        break;       
      } 
     } 
     
   if(flag==1)
   {
     String   sql1="update 操作员 set 签入标志=0 where 操作员帐号= '"+userid+"'";
       int   pa=stmt.executeUpdate(sql1);
        if(pa==1)
        { 
  %>
  <div id="Layer3" style="position:absolute; width:20%; height:20%; z-index:1; left: 47%; top: 60%"><font color="red" size="3">
  <%
    out.println("复位成功!");
  
      }
    stmt.close();
    conn.close();
       
  }else
  {
    %>
       <% out.println("");
          out.println("<h3 >复位失败,请正确输入操作员账号!</h3>");
       %>
 
  
  </font>
 </div>
  <% 
    
  }
   
   } catch(Exception e)
  {
  e.printStackTrace();
  }
  }
  %>上面是我写的代码,为什么会在获得id这个字符串变量时会产生空格呢?
在红色标记的代码中,上面是正确的,程序可以正常运行
而下面的一句则不会运行。