日期:2014-05-17  浏览次数:20840 次

用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相关代码
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.aiyiweb.com/java-web/317.html