ITeye博客

response的reset和resetBuffer

androider · 2007-11-29 20:13 · Markdown

使用struts2的getResponse的getWriter()方法连续两次输出流到页面的时候,第二次的流会包括第一次的流,所以可以使用将response.reset或者resetBuffer的方法。

reset(): Clears any data that exists in the buffer as well as the status code and headers. If the response has been committed, this method throws an IllegalStateException.

resetBuffer(): Clears the content of the underlying buffer in the response without clearing headers or status code. If the response has been committed, this method throws an IllegalStateException.

评论(1)

  1. #1 楼 · 青春的、脚步 · 2012-12-01 09:43

    at org.mortbay.jetty.Response.resetBuffer(Response.java:853) at org.mortbay.jetty.Response.reset(Response.java:832) at org.mortbay.jetty.Response.sendError(Response.java:220) at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:801) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:519) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)

    这个是你说的第二个原因吗?

评论功能维护中,当前仅展示历史评论。