首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

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

2013-09-11 
用equals函数比较两字符串是否一样出现错误,望大神帮解决错误提示type Exception reportmessagedescriptio

用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.myexception.cn/java-web/317.html

热点排行