JSP解决:Attempt to clear a buffer that's already been flushed错误(jsp:forward标签跳转空白)
[摘要:本日正在开辟过程当中发明一个题目:正在页里中应用了jsp:forward扔错Attempt to clear a buffer that's already been flushed!! 百思没有得其解!! 谷歌之,得以下说明: 通例,先上中文论坛搜刮谜底 h]
今天在开发过程中发现一个问题:在页面中使用了<jsp:forward>抛错Attempt to clear a buffer that's already been flushed!!
百思不得其解!!
google之,得如下解释:
惯例,先上外文论坛搜索答案
http://www.coderanch.com/t/484489/JSP/java/JSP-working
其中有一句话,解释了这个问题的发生:
When you forward a request to another resource.. whose response is already commited.. then it throws this exception.
A request that is being forwarded should not have commited.
In your case, when the JSP is being executed, it might have generated some html content before it is forwarding.
If the server has send these html content to a client before you forward the request to another resource, then it throws an illegal state exception if you try to forward.
As you increased the buffer size, then the server is not actually sending the generated html content to client (Till the buffer fills up).. and on forward the buffer will be cleared.
意思大致是:当你通过forward请求另一个资源的时候,如果你的服务器已经向client响应了数据,就是所你原来未跳转之前的页面已经存在数据了(我的页面情况是:forward前面通过连接数据库查询到数据赋值给了select下拉列表了),所以就会报错,而设大缓冲区的话,服务器就不会立即响应给服务端,而是等所有页面加载完成之后,或者缓冲区满了之后才会发送响应给用户,
我的解决办法,在jsp开头加入缓冲区设置语句
1 <%@ page autoFlush="true" buffer="1094kb"%>
buffer大小视实际情况来定。。
原文出处(http://www.ithao123.cn/content-100640.html)