当我尝试将 JSP 的数据保存在 EXCEL 中时,我从 Tomcat 服务器收到 IllegalStateException。IllegalStateException
可能发生在以下任何一种情况下:
- 如果后面没有return语句
sendRedirect()
。 - 如果 POST 大小大于 2MB。
- 如果页面缓冲区大小较小。
除此之外,还有什么原因IllegalStateException
吗?
我的代码:
response.sendRedirect(response.encodeRedirectURL(request.getRequestURI() + "?saveToFile=true&action=" + ReportsManager.ACTION_SAVE_AS_XLS + "&saveFileName=" + saveFileName + "&returnPage=" + StringFunctions.encodeUrlParameter(returnPage)));
return;
我正在IllegalStateException
使用 sendRedirect()。
此外,如果 JSP 中只有很少的记录(比如 100 行),则保存为 Excel 不会出错。如果有 1000 条记录,那么我得到IllegalStateException
.
堆栈跟踪:
*Mar 25, 2013 6:57:26 AM,JSP Runtime Error,0,java.lang.IllegalStateException
at org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect(CoyoteResponseFacade.java:352)
at org.apache.jsp.OperationalReports.SalespersonSales_jsp._jspService(SalespersonSales_jsp.java:2567)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.retailJava.core.filters.SecurityFilter.doFilter(SecurityFilter.java:136)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:595)
如果我设置页面缓冲区大小,那么它适用于 1000 条记录。但如果它达到 2000 条记录,那么我又遇到了问题。
<%@ page buffer = "2048kb" autoFlush = "true" %>