java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
来源:互联网 发布:浙江省儿童dna数据库 编辑:程序博客网 时间:2024/05/01 01:32
java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本人声明。否则将追究法律责任。
作者:永恒の_☆ 地址:http://blog.csdn.net/chenghui0317/article/details/9531171
作者:永恒の_☆ 地址:http://blog.csdn.net/chenghui0317/article/details/9531171
做开发的时候,有时候报错:
java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
字面上是参数异常, 在response已经提交之后 不能发送错误请求。
下面看个例子就一目了然了:
首先,利用reponse.getWrite()获得输出流对象,close()之后,这里reponse其实已经提交了。注释下面的sendRedirect代码,执行之后发现response已经进行已经跳转了,只不过url没有发生改变,并且页面上已经有输出上面指定的字符串。
所以当执行上面代码之后 ,reponse 会提交两次,服务器就不知道该怎么办了,所以抛出异常。
解决方案: 去掉out.close() 这里不会因为PrintWriter 输出对象没有关闭而占用资源的。
阅读全文
0 0
- java.lang.IllegalStateException: Cannot call sendError() after the response has been committed错误
- java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
- java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
- java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
- java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
- 【SSH问题】java.lang.IllegalStateException: Cannot call sendError() after the response has been committe
- Cannot call sendError() after the response has been committed
- Cannot call sendError() after the response has been committed
- Cannot call sendError() after the response has been committed
- Cannot call sendError() after the response has been committed
- Cannot call sendError() after the response has been committed
- struts2文件图片流输出报IllegalStateException: Cannot call sendError() after the response has been committed
- java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed
- java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed
- java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed
- Java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed
- java.lang.IllegalStateException: Cannot forward after response has been committed
- java.lang.IllegalStateException: Cannot forward after response has been committed
- Oracle 13c OEM 安装测试(13.2.0.0)
- IntelliJ IDEA2017.3 激活
- MongoDB和MySQL的区别
- 史上最简单的SpringCloud教程 | 第六篇: 分布式配置中心(Spring Cloud Config)
- 公司通过微信风控系统实时监控员工微信聊天记录
- java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
- View的滑动冲突
- [杜教筛] 51nod1220. 约数之和
- csdn的第一天
- 百度地图SDK申请之获取发布版,开发版SHA1
- 史上最简单的SpringCloud教程 | 第七篇: 高可用的分布式配置中心(Spring Cloud Config)
- MySQL explain执行计划解读
- 腾讯AI Lab刷新人脸检测与识别两大测评国际记录,技术日调用超六亿
- 30岁转行做初级程序员是一种怎样的体验?