getResponse的getWriter()方法

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.

response.reset()的使用有一个条件受限:response的任何打开流关闭之后都不能再reset .

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.

可以看到resetBuffer方法与reset方法的区别是,头和状态码没有清除。

一般用于下载文件excel操作时:

空白行的出现原因,jsp代码编译后产生。就是有jsp生成html文件的时候,html文件内部会出现很多空白行。下载后的文件内的空白行也是这样产生的。
因此,需要 response.reset() 来清除首部的空白行。

最新文章

  1. Spring Boot 之 HelloWorld详解
  2. Android实例-MotionSensor加速度(XE8+小米2)
  3. js 验证输入框金额
  4. iOS程序生命周期 AppDelegate
  5. 【Flex】读取本地XML,然后XML数据转成JSON数据
  6. Scala环境搭建之eclipse
  7. jQuery学习之旅 Item2 选择器【二】
  8. nmon监控分析
  9. MAC终端神器iterm2——告别黑白
  10. shell 日常技巧
  11. python之匿名函数以及在内置函数中的使用
  12. H5 58-网页的布局方式
  13. SSH配置struts校验发生No result defined for action actions.AdminLoginAction and result input
  14. Java学习笔记(二十):多态
  15. Python 浅谈编程规范和软件开发目录规范的重要性
  16. Tomcat 9.0 配置问题 403 Access Denied
  17. python threading模块使用 以及python多线程操作的实践(使用Queue队列模块)
  18. 《完美应用ubuntu》之全面管理ubuntu软件源
  19. Windows安装PostgreSQL数据库 无法初始化数据库问题
  20. Error message: “'chromedriver' executable needs to be available in the path”

热门文章

  1. Oracle GoldenGate 一、介绍和安装
  2. jdbc注册驱动 class.forName()
  3. 一起做RGB-D SLAM(7) (完结篇)
  4. LVS初步
  5. Asp.NetCore MVC Web 应用
  6. [python01] python列表,元组对比Erlang的区别总结
  7. Bug报告提交规范
  8. nginx 托管.net core的service文件
  9. [SSH]struts2-spring-plugin.jar了解
  10. java学习笔记—EL表达式(38)