我正在尝试使用 Servlet 将数据下载为 CSV,并且 JSP 包含在flush=true
. 下面提供了堆栈跟踪。该报告正在按预期保存,但我可以在后面看到一个异常。你能帮我弄清楚为什么吗?我已经关闭OutputStream
并尝试刷新缓冲区,但仍然没有运气。
1:36:38,304 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:619)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)
at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:173)
at atg.taglib.dspjsp.IncludeTag.flushOut(IncludeTag.java:873)
at atg.taglib.dspjsp.IncludeTag.doEndTag(IncludeTag.java:773)
pResponse.setContentType(MS_EXCEL);
pResponse.setHeader(CONTENT,FILENAME);
outputStream = pResponse.getOutputStream();
pResponse.flushBuffer();
workbook.write(outputStream);
outputStream.flush();
outputStream.close();