File rpt = new File(application.getRealPath("/ord/rpt/orderinfor.jasper"));
Class.forName(driver);
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(rpt);
con = DriverManager.getConnection(url, "xzs_network", "xzs");
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
if (!rs.next())
return;
jrds = new JRResultSetDataSource(rs);
jasperPrint =
JasperFillManager.fillReport(
jasperReport,
reportParams,
jrds
);
JasperPrintManager.printReportToXmlStream(jasperPrint,response.getOutputStream());
response.getOutputStream().flush();
response.getOutputStream().close();
------------------------------------------------------------------------
抛出异常如下:
java.lang.IllegalStateException: getOutputStream() has already been called for this response
java.lang.IllegalStateException: getOutputStream() has already been called for this response
怎么解决呢?
7 个解决方案
#1
意思是输出流已经被打开,不允许操作了,怎么回这样呢?
#2
ServletOutputStream output = response.getOutputStream();
JasperPrintManager.printReportToXmlStream(jasperPrint,output);
output .flush();
output .close();
#3
可以try try.
http://www.javatoolsoft.com JavaCellReport
一个完全用java写出的Excel,同时支持数据帮定和Web浏览和打印.
http://www.javatoolsoft.com JavaCellReport
一个完全用java写出的Excel,同时支持数据帮定和Web浏览和打印.
#4
帮忙顶
#5
up
#6
up!
up!
up!
#7
我也遇到这样的情况,删除掉页面上面的<%@ page contentType="application/pdf;charset=GB2312" %>
#1
意思是输出流已经被打开,不允许操作了,怎么回这样呢?
#2
ServletOutputStream output = response.getOutputStream();
JasperPrintManager.printReportToXmlStream(jasperPrint,output);
output .flush();
output .close();
#3
可以try try.
http://www.javatoolsoft.com JavaCellReport
一个完全用java写出的Excel,同时支持数据帮定和Web浏览和打印.
http://www.javatoolsoft.com JavaCellReport
一个完全用java写出的Excel,同时支持数据帮定和Web浏览和打印.
#4
帮忙顶
#5
up
#6
up!
up!
up!
#7
我也遇到这样的情况,删除掉页面上面的<%@ page contentType="application/pdf;charset=GB2312" %>