当前位置: 代码迷 >> Java Web开发 >> 用equals函数比较两字符串是否一样出现异常,望大神帮解决
  详细解决方案

用equals函数比较两字符串是否一样出现异常,望大神帮解决

热度:789   发布时间:2013-02-25 21:09:31.0
用equals函数比较两字符串是否一样出现错误,望大神帮解决

错误提示 
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException
Email.check.doPost(check.java:84)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.


代码出错位置:
if(rs.next())
  {  
  String str=rs.getString("password");
  if(userpassword.trim().equals(str.trim())) (第84行,试过if(userpassword.equals(str)))
  {  
  String script = "<script>location.href=\"" + req.getContextPath() + "/test.jsp\"</script>";
  resp.getWriter().println(script);
  }
}

------解决方案--------------------------------------------------------
探讨
错误提示
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException
Email……

------解决方案--------------------------------------------------------
按你所说的,str应该为null
------解决方案--------------------------------------------------------
错误应该还在上边,请贴出rs相关代码
  相关解决方案