Java Web报错:getOutputStream() has already been called for this response解决方案
今天做了个导出excel表的功能。大概代码如下:
ouputStream = response.getOutputStream();
wb.write(ouputStream);
ouputStream.flush();
ouputStream.close();
1
2
3
4
发现报错
java.lang.IllegalStateException: getOutputStream() has already been called for this response
1
报错原因
getOutputStream方法用于返回Servlet引擎创建的字节输出流对象,Servlet程序可以按字节形式输出响应正文。
getWriter方法用于返回Servlet引擎创建的字符输出流对象,Servlet程序可以按字符形式输出响应正文。
getOutputStream和getWriter这两个方法互相排斥,调用了其中的任何一个方法后,就不能再调用另一方法。
解决方案有两种:
在jsp页面里清除response。
out.clear();
out = pageContext.pushBody(http://www.my516.com);
1
2
在controller层对应的方法上追加@ResponseBody。
---------------------
Java Web报错:getOutputStream() has already been called for this response解决方案的更多相关文章
- Java Web报错: GET http://localhost:8080/ 404 (Not Found)
eclipse正常启动tomcat,但是 访问http://localhost:8080 报404错误 搞笑的是我访问服务器中的其他网页也可以打开 报错如下: 解决: 如果这3项都已经变灰色,删除配置 ...
- Java Web报错:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
问题描述: 我们在用Eclipse进行Java web开发时,可能会出现这样的错误:The superclass javax.servlet.http.HttpServlet was not foun ...
- JSON.toJSONString(joinPoint.getArgs())报错getOutputStream() has already been called for this response
nested exception is java.lang.IllegalStateException: It is illegal to call this method if the curren ...
- Oracle EBS Java Applet报错:找不到类
Oracle EBS Home Page可以打开,但是无法打开EBS的Form,查看Java控制台,有错误报出. java控制台报错,如下: Java Plug-in 1.6.0_07 使用 JRE ...
- android studio java工程 报错
作者:韩梦飞沙 Author:han_meng_fei_sha 邮箱:313134555@qq.com E-mail: 313134555 @qq.com android studio java工程 ...
- Centos7 JDK安装过程中 解决java -version 报错: bash: /home/jdk1.8.0_161/bin/java: Permission denied
1.执行Linux命令 -----vim /etc/profile 编辑profile 文件,在里面添加: #set java enviroment JAVA_HOME=/opt/JavaHome ...
- debug运行java程序报错
debug运行java程序报错 ERROR: transport error 202: connect failed: Connection timed out ERROR: JDWP Transpo ...
- java @override 报错处理
转载自:http://blog.sina.com.cn/s/blog_9c7605530101kl9r.html 一.java @override 报错处理 做项目的时候,同事那边电脑上编译通过的ja ...
- php通过JavaBridge调用Java类库和不带包的自定义java类成功 但是调用带包的自定义Java类报错,该怎么解决
php通过JavaBridge调用Java类库和不带包的自定义java类成功 但是调用带包的自定义Java类报错,Class.forName("com.mysql.jdbc.Driver&q ...
随机推荐
- 让你的Kivy支持中文字符
前言 默认Kivy字体不支持中文,本文简单描述如何让你的应用支持中文字符 代码 from kivy.app import App from kivy.core.text import LabelBas ...
- Git Reference
Installing and upgrading Git https://confluence.atlassian.com/bitbucketserver056/installing-and-upgr ...
- ldap第一天 编译安装LDAP + ldapadmin
此文整理学习此大神的博客:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=26168435&id=5746284 一.环 ...
- 关于unique去重
嗯.... unique这个东西也是一个冷门知识..... 但是在有时候它还是比较好用的东西... 下面就在详细代码中看unique是如何实际应用的....它主要是用于数组去重 #include< ...
- giihub上的关于js的43道题目
参考 https://github.com/lydiahallie/javascript-questions
- Regionals 2014 >> Asia - Taichung 7003 - A Balance Game on Trees 树形DP + 二维费用背包
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...
- URAL 1948 H - The Robot on the Line 二分 + 数学
http://acm.hust.edu.cn/vjudge/contest/126149#problem/H 给定一条二次函数 f (x) = a * x * x + b * x + c 求一个最小的 ...
- 由Python的浅拷贝(shallow copy)和深拷贝(deep copy)引发的思考
首先查看拷贝模块(copy)发现: >>> help(copy)Help on module copy:NAME copy - Generic (shallow and dee ...
- dojo topic 发布与订阅 小例子可以参考下
<!DOCTYPE html><html> <head> <title></title></head> <body> ...
- ssm(Spring、Springmvc、Mybatis)实战之淘淘商城-第十三天(非原创)
文章大纲 一.课程介绍二.SolrCloud介绍与搭建三.工程部署四.参考资料下载五.参考文章 一.课程介绍 一共14天课程(1)第一天:电商行业的背景.淘淘商城的介绍.搭建项目工程.Svn的使用 ...