2 a8200232 a8200232 于 2016.09.12 17:41 提问

servlet传递参数到jsp报错,请帮忙看一下

                                 sql = "select * from component_list";                           
                                 rs=stmt.executeQuery(sql);     

                                 sql1 = "select * from express_list where account_name = '"+userName+"' and status = '已请求'";
                                 rs1=stmt.executeQuery(sql1);

                                 req.setAttribute("rs_artbut",rs);    
                                 req.setAttribute("rs_artbut1",rs1);    

                                 RequestDispatcher view_rec = req.getRequestDispatcher("rec.jsp");
                                 view_rec.forward(req,resp);
                             default :
                                 out.println("error");
                                 break;

                    out.println("</table>");
                    rs.close();
                                        rs1.close();
                    stmt.close();
                    conn.close();   

浏览器打印错误为:org.apache.jasper.JasperException: javax.servlet.ServletException: java.sql.SQLException: Operation not allowed after ResultSet closed

2个回答

qq455276333
qq455276333   Rxr 2016.09.12 17:48
已采纳
a8200232
a8200232 对对。感谢
大约一年之前 回复
Marksinoberg
Marksinoberg   Ds   Rxr 2016.09.12 18:13

RequestDispatcher 是一个转发器,也就是说结果集会跟随其传递到jsp页面,你这里贸然的关掉,就有可能出现sqlEcxeption了。

建议改改再试试吧。

Csdn user default icon
上传中...
上传图片
插入图片