java.lang.IllegalStateException: getOutputStream() has already been called for this response
ERROR [Engine] StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
从网上找了下资料,综合一下原因分析:
这是web容器生成的servlet代码中有out.write(””),这个和JSP中调用的response.getOutputStream()产生冲突.
即Servlet规范说明,不能既调用 response.getOutputStream(),又调用response.getWriter(),无论先调用哪一个,在调用第二个时候应会抛出 IllegalStateException,因为在jsp中,out变量是通过response.getWriter得到的,在程序中既用了response.getOutputStream,又用了out变量,故出现以上错误。
解决方案:
1.在程序中添加:
out.clear();
out = pageContext.pushBody();
就可以了;
2,不要在%〕〔%之间写内容包括空格和换行符
3,在页面写入图片的时候,需要flush()
OutputStream output=response.getOutputStream();
output.flush();
4,在页面确定写入<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312”>
java.lang.IllegalStateException: getOutputStream() has already been called for this response的更多相关文章
- 用java实现文件下载,提示java.lang.IllegalStateException: getOutputStream() has already been called for this response
1. 用java实现文件下载,提示java.lang.IllegalStateException: getOutputStream() has already been called for this ...
- 严重: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called for this response
严重: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputS ...
- 终极解决方案:org.apache.jasper.JasperException: java.lang.IllegalStateException: getOutputStream() has already been called for this response
一.项目 我的项目采用Spring MVC +JSP+EasyUI 做的老项目. 在做图片验证码方法时,向网页输出验证码图片的方法如下: @Override public void showCodeI ...
- java.lang.IllegalStateException: getOutputStream() has already been called for this response解决方案
异常产生原因:web容器生成的servlet代码中有out.write(""),这个和JSP中调用的response.getOutputStream()产生冲突.即Servlet规 ...
- Request processing failed; nested exception is java.lang.IllegalStateException: getOutputStream() has already been called for this response
问题分析: 在ServletRequest servletRequest中已经存在一个项目名称,此时,又用项目名称访问 http://localhost:8080/rent/pdf/preview r ...
- 严重: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called
错误: 严重: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutput ...
- java.lang.IllegalStateException: getWriter() has already been called for this response问题解决
java.lang.IllegalStateException: getWriter() has already been called for this response问题解决 java.lang ...
- springMVC java.lang.IllegalStateException: getOutputStream() has already bee
在导出文件的时候,一直报这个错误. 网上一般的做法是out.clear();或者使用servlet或者Action返回null. 试过了这些方法都不成功. 最后直到试了在jsp重定向的方法才成功了. ...
- java.lang.IllegalStateException: getOutputStream() has already been called 解决办法
因为在使用的时候没有使用@ResponseBody这个注解,所以才会报上面的异常
随机推荐
- linux基础知识与技能1
1.隐藏文件与非隐藏文件Linux中:linux中隐藏文件特点是文件名以.开头,跟文件属性无关.在linux中查看隐藏文件用ls -a命令(普通显示ls)2.相对路径与绝对路径什么是路径:路径是用来标 ...
- HIbernate的property-ref属性
为公司之前的一个公交卡系统修改bug: 通过排查发现, 卡类型表和卡等级表是一对多的关系, 但是卡等级表中没有字段引用卡类型表的主键,而是引用了卡类型表中非主键的另外两个字段 通过查看hibernat ...
- TCP/IP协议
1.为什么有了IP地址还需要MAC地址? 首先,数据或者信息在网络上的传输需要两个地址:目的地址和下一跳地址.其中IP地址就是目的地址,而MAC地址则是下一跳地址.目的地址在经过路由器转发的时候是不会 ...
- mui,css3 querySelector,appendChild,style.display,insertBefore
<script> mui.init({ swipeBack:true //启用右滑关闭功能 }); window.addEventListener('toggle', function(e ...
- 让你Android开发更简单
转载:http://www.jianshu.com/p/22ff8b5fdadc 搭建一个新的Android项目,你会怎么做? 每个人对应用框架的理解不相同,但是最终达到的效果应该是一样: ①降低项目 ...
- 架构师养成记--4.volatile关键字
volatile修饰的变量可在多个线程间可见. 如下代码,在子线程运行期间主线程修改属性值并不对子线程产生影响,原因是子线程有自己独立的内存空间,其中有主内存中的变量副本. public class ...
- bae上传图片失败
出错原因:bae不支持文件写入.
- HTML-一个网页的头部的大概框架(完善ing)
正常情况下,一个头部(考虑兼容.响应.title图标的需求),所要填写的内容如下: <!DOCTYPE html> <html> <head> <meta c ...
- java支持跨平台获取cpuid、主板id、硬盘id、mac地址 (兼容windows、Linux)
windows: package cn.net.comsys.helper.system.info; import java.io.BufferedReader; import java.io.F ...
- 数据存储_SQLite常用的函数
一.简单说明 1.打开数据库 int sqlite3_open( const char *filename, // 数据库的文件路径 sqlite3 **ppDb // 数据 ...