用!equals(request.getParameter("passwd"))

解决方案 »

  1.   

    对于字符串的比较应该用equals()方法。
      if(rs.getString("us_password").equals(request.getParameter("passwd")))
       { 
    }如果用“==”,只有当两个变量指向同一引用的时候才会相等
      

  2.   

    if(!rs.getString("us_password").equalsrequest.getParameter("passwd"))
       { 
       response.sendRedirect("http://localhost:8080/myjsp/errorPage.htm");
      }
      else
      {
       response.sendRedirect("http://localhost:8080/myjsp/Query.htm");
      }
      

  3.   

    字符串的比较应该用equals()方法
    ==是比较句柄,当然不相等。
      

  4.   

    应该使用字符串比较函数进行字符串的比较!如string1.equals(string2);不相等可以用    !string1.equals(string2);
      

  5.   

    试试这个
    --------------if(!rs.getString("us_password").equals((String)request.getParameter("passwd")))
       { 
       response.sendRedirect("http://localhost:8080/myjsp/errorPage.htm");
      }
      else
      {
       response.sendRedirect("http://localhost:8080/myjsp/Query.htm");
      }
      

  6.   

    request.getParameter (“”)得到的可能是个对象 转化成 String 试试
      

  7.   

    试试这个
    --------------if(!rs.getString("us_password").equals((String)request.getParameter("passwd")))
       { 
       response.sendRedirect("http://localhost:8080/myjsp/errorPage.htm");
      }
      else
      {
       response.sendRedirect("http://localhost:8080/myjsp/Query.htm");
      }
    支持
      

  8.   

    注意在java中String 是对象,用==是表示两个对象在内存中是否在同一地址。你试一下下面的例子感觉一下两者的区别吧。
    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head><body>
    <%
    String param1="123";
    String param2="123";
    if(param1==param2){
    out.println("true");
    }
    else{
    out.println("false");
    }
    %>
    <br>
    <hr>
    <%
    String parameter1=new String("123");
    String parameter2=new String("123");
    if(parameter1==parameter2){
    out.println("true");
    }
    else{
    out.println("false");
    }
    %></body>
    </html>
      

  9.   

    说说 字符窜的“==”和equals的区别
      “==”判断两个字符窜的引用是否相同,equals判断两个字符窜的值是否相同。