Servlet“响应已提交"的原因 [英] Cause of Servlet's 'Response Already Committed'
问题描述
在 servlet 中遇到此异常的常见可能性有哪些 - 响应已提交?
What are the common possibilities to encounter this exception in servlet - Response Already committed?
推荐答案
响应被提交的原因如下:
The response gets committed because of the following reasons:
因为响应缓冲区已达到最大缓冲区大小.可能是因为以下原因:
Because the Response buffer has reached the max buffer size. It could be because of the following reasons:
> the bufferSize in JSP page has reached.You can increase the JSP buffer size
in page directive. See here,
<%@ page buffer="5kb" autoFlush="false" %>
> the server default response max buffer size has reached.You can increase
the server default max buffer size.
ServletRespnse.setBufferSize()
部分代码在响应上调用了flushed,即调用了HttpServletResponse.flushBuffer()
方法.
部分代码刷新了OutputStream
或Writer
,即调用了HttpServletResponse.getOutputStream().flush()
或 `HttpServletResponse.getWriter().flush()
Some part of the code has flushed the OutputStream
or Writer
, i,e, invoked the method HttpServletResponse.getOutputStream().flush()
or `HttpServletResponse.getWriter().flush()
如果您已转发到另一个页面,该页面的响应既已提交又已关闭.例如,当 response.sendRedirect() 被调用时,响应被提交.
If you have forwarded to another page, where the response is both committed and closed. For example, when response.sendRedirect() has been called, the response is committed.
这篇关于Servlet“响应已提交"的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!