response.sendRedirect()有什么用?
使用 respone.sendRedirect("page.jsp")
时,它显示 java.lang.IllegalStateException
,而在某些页面中它执行正常。我怎样才能避免这个异常?有关更多详细信息,我昨天通过了一个与此类似的问题。
while using respone.sendRedirect("page.jsp")
it was showing java.lang.IllegalStateException
, while in some pages it was executing properly. How can I avoid this exception? For more details I passed yesterday a question that was simillar to this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的响应已提交,
respone.sendRedirect
将抛出java.lang.IllegalStateException
。您要么手动刷新缓冲区,要么因为缓冲区已满而自动刷新。为了避免这种情况,请增加缓冲区大小并确保不会刷新它,或者尽早调用respone.sendRedirect
。respone.sendRedirect
will throwjava.lang.IllegalStateException
if your response is already committed. You have either manually flush the buffer or it was automatically flushed because it was full. To avoid this, either increase the buffer size and make sure that you are not flushing it or callrespone.sendRedirect
early.