if (s == "aaaa")
->
if ("aaaa".equals(s))

解决方案 »

  1.   

    request.getParameter("name").trim();行不行?
      

  2.   

    if (s == "aaaa")
    ???????????????/
    if(s.equals("aaaa"))
      

  3.   

    if (s == "aaaa")
    ???????????????/
    if(s.equals("aaaa"))
      

  4.   

    这是字符串比较的特殊之处。在java中,字符串是对象,"aaaa"与s是两个对象,是不能使用==来比较子串内容的。因此java提供了equals方法。改进方法同gzwrj(我无知,所以我有智慧.) 的建议。
      

  5.   

    有问题吗???
    getParameter("name"); //这里错了??
      

  6.   

    if (s == "aaaa")
    ???????????????/
    if(s.equals("aaaa"))
      

  7.   

    我还以为String象(MFC里面的CString)重载了 == 的操作符了,原来没有....
      

  8.   

    同意chesterwoo() 
    在java中字符串是以对象的形式出现的
    “==”表示String对象之间的比较
    只有这样比较才为truepublic class Str {
      static String str1="Java";
      static String str2=str1;
      static String str3=str1;
      public static void main(String agrs[]){    System.out.println(str2==str3);
      }
    }结果为true。