用request的方法返回的字符串在if的判斷中出錯
用字符串的長度判斷為什么出錯?
String name=request.getParameter("username");
?????? if(name.length()!=0)
?????? {
??? ?? out.println("登陸成功");
?????? }
用字符串的長度判斷為什么出錯?
String name=request.getParameter("username");
?????? if(name.length()!=0)
?????? {
??? ?? out.println("登陸成功");
?????? }
2017-11-24
舉報
2018-10-25
name可能為null,在null上用length會出現(xiàn)“NullPointerException“錯誤
2017-11-25
username沒有value時就會出錯,并不是name為null