当前位置: 代码迷 >> Java Web开发 >> 空指针有关问题,求解决办法,
  详细解决方案

空指针有关问题,求解决办法,

热度:142   发布时间:2016-04-17 12:21:22.0
空指针问题,求解决方法,急啊
提交登入表单时,出现错误
  description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: Exception in JSP: /pages/login.jsp:25

22: ResultSet rs=jdbc.executeQuery(sql);
23: //out.print(sql);
24: //out.close();
25: if(rs.next()){
26: user_Id=rs.getInt("user_Id");
27: uname=rs.getString("uname");
28: cname=rs.getString("cname");


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause 

java.lang.NullPointerException
org.apache.jsp.pages.login_jsp._jspService(login_jsp.java:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.16 logs.



我知道是rs这个对象可能为空,我还用.next()的方法,但是问题是,我不知道怎么解决,请高手赐教!
  PS:数据库连好了没我也不知道



------解决方案--------------------
加断点 看sql语句是否正确 
正确的话 看你得数据库连接是否成功
------解决方案--------------------
rs是否为空 打印出来看一下 判断如果为空 直接返回!
代码迷推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.daimami.com/search?q=317
  相关解决方案