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