Topic: 菜鸟问题,希望大虾们帮助 |
Print this page |
1.菜鸟问题,希望大虾们帮助 | Copy to clipboard |
Posted by: J2EE1982 Posted on: 2005-08-16 07:42 jsp:源程序 <%@ page language = "java" contentType = "text/html;charset=ISO-8859-1" %> <%@ page import = "java.sql.*" %> <jsp:useBean id="mysql" scope="page" class="com.Mysql" /> <% ResultSet rs = mysql.executeQuery("select * from stsnews"); while(rs.next()) { out.println(rs.getString("title")); } %> 错误:type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause java.lang.NullPointerException org.apache.jsp.index_jsp._jspService(index_jsp.java:59) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) |
2.Re:菜鸟问题,希望大虾们帮助 [Re: J2EE1982] | Copy to clipboard |
Posted by: chengbd Posted on: 2005-08-17 01:12 java.lang.NullPointerException 这是运行时错误了,没看到你的DB连接代码,应该是rs是个null值,却执行rs.next(),就出错了。 应该 ResultSet rs = mysql.executeQuery("select * from stsnews"); if(rs==null){ } else { while(rs.next()) { out.println(rs.getString("title")); } } |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |