JSP编译出现异常,求解答。
typeExceptionreportmessagedescriptionTheserverencounteredaninternalerror()thatprevent...
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /ShowArticleTree.jsp at line 49
46:
47: Statement stmt = conn.createStatement();
48: ResultSet rs = stmt.executeQuery("select * from article where pid= 0");
49: while(rs.next()){
50: str+="<tr><td>"+ rs.getInt("id")+"</td><td>"+
51: rs.getString("cont") +"</td></tr>";
52: if(rs.getInt("isleaf")!=0){
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.ServletException: java.sql.SQLException: Operation not allowed after ResultSet closed
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
org.apache.jsp.ShowArticleTree_jsp._jspService(ShowArticleTree_jsp.java:143)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.sql.SQLException: Operation not allowed after ResultSet closed
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
com.mysql.jdbc.ResultSetImpl.checkClosed(ResultSetImpl.java:794)
com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7145)
org.apache.jsp.ShowArticleTree_jsp._jspService(ShowArticleTree_jsp.java:105)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
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.30 logs.
while循环里其实就只剩下一个方法了,我把方法贴出来。
if(rs.getInt("isleaf")!=0){
tree(conn,rs.getInt("id"),1);
}
private void tree(Connection conn,int id,int level){
Statement stmt = null;
ResultSet rs = null;
String preStr = "";
for(int i=0;i<level;i++){
preStr += "----";
}
try{
stmt = conn.createStatement();
String sql = "select * from article where pid = "+id;
rs = stmt.executeQuery(sql);
while(rs.next()){
str +="<tr><td>"+ rs.getInt("id")+"</td><td>"+
preStr +rs.getString("title") +"</td></tr>";
if(rs.getInt("cont")!=0){
tree(conn,rs.getInt("id"),level+1);
}
}
}catch(SQLException e){
e.printStackTrace();
}finally{try{if(rs !=null){rs.close();rs = null;}if(stmt !=null){stmt.close();
stmt = null;
}
}catch (SQLException e){
e.printStackTrace(); 展开
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /ShowArticleTree.jsp at line 49
46:
47: Statement stmt = conn.createStatement();
48: ResultSet rs = stmt.executeQuery("select * from article where pid= 0");
49: while(rs.next()){
50: str+="<tr><td>"+ rs.getInt("id")+"</td><td>"+
51: rs.getString("cont") +"</td></tr>";
52: if(rs.getInt("isleaf")!=0){
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.ServletException: java.sql.SQLException: Operation not allowed after ResultSet closed
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
org.apache.jsp.ShowArticleTree_jsp._jspService(ShowArticleTree_jsp.java:143)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.sql.SQLException: Operation not allowed after ResultSet closed
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
com.mysql.jdbc.ResultSetImpl.checkClosed(ResultSetImpl.java:794)
com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7145)
org.apache.jsp.ShowArticleTree_jsp._jspService(ShowArticleTree_jsp.java:105)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
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.30 logs.
while循环里其实就只剩下一个方法了,我把方法贴出来。
if(rs.getInt("isleaf")!=0){
tree(conn,rs.getInt("id"),1);
}
private void tree(Connection conn,int id,int level){
Statement stmt = null;
ResultSet rs = null;
String preStr = "";
for(int i=0;i<level;i++){
preStr += "----";
}
try{
stmt = conn.createStatement();
String sql = "select * from article where pid = "+id;
rs = stmt.executeQuery(sql);
while(rs.next()){
str +="<tr><td>"+ rs.getInt("id")+"</td><td>"+
preStr +rs.getString("title") +"</td></tr>";
if(rs.getInt("cont")!=0){
tree(conn,rs.getInt("id"),level+1);
}
}
}catch(SQLException e){
e.printStackTrace();
}finally{try{if(rs !=null){rs.close();rs = null;}if(stmt !=null){stmt.close();
stmt = null;
}
}catch (SQLException e){
e.printStackTrace(); 展开
展开全部
"text/html; charset=UTF-8" language="java" %>
然后用记事本打开该jsp文件,另存为,选择编码为UTF-8。
然后用记事本打开该jsp文件,另存为,选择编码为UTF-8。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把while整段代码贴出来看看
追问
补全了,请再帮我看看。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
听 wujiazhao1988 的把, 另外补全下那断代码.
追问
补全了,请再帮我看看。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询