Action 中 Response already committed 解决办法
来源:互联网 发布:网络转换器网通转电信 编辑:程序博客网 时间:2024/05/10 06:43
在一个roundtrip中response只能被发出一次,在一些验证码、文件下载中通过httpServletResponse.getOutputStream()和requestOutputStream.write()等方法已将response发出,再return ActionForward时被认为是再发送一次,因而报错。出现这种情况的时候,后面的return将只可以返回null,这可以由httpServletResponse.iscommitted()获知。
代码如下:
public class CheckCode extends BaseAction {private static final long serialVersionUID = 1L;public String execute() throws Exception {String checkCode = String.valueOf(new Random().nextInt(8999)+1000);this.getSession().setAttribute("ImageCode", checkCode);CodeImage.getInstanse().getImage(this.getResponse(), checkCode);/** add by zhangWei Feb 18, 2013 4:38:15 PM Reason : 这里添加一个判断, * 如果response.isCommitted()==true,返回数据会导致再次发送一次response, * 导致出现:Response already committed异常,返回null解决此问题*/return this.getResponse().isCommitted()?null:SystemStaticConstant.SUCCESS;}}
在CodeImage.getInstanse().getImage(this.getResponse(), checkCode);中有这么一行代码:
ImageIO.write(image, "JPEG", response.getOutputStream());
- Action 中 Response already committed 解决办法
- captcha验证码在weblogic 下报java.io.IOException: response already committed的解决办法
- java.io.IOException: response already committed
- java.io.IOException: response already committed
- java.io.IOException: response already committed
- java.io.IOException: response already committed
- java.lang.IllegalStateException: Response has already been committed
- Cannot forward a response that is already committed
- weblogic 11g java.io.IOException: response already committed
- Cannot set header. Response already committed及response.sendRedirect报java.lang.IllegalStateException的一次解决
- weblogic下抛java.lang.IllegalStateException: response already committed tomcat下正常
- [JACA][WAS]WAS6报警告解决方法之:WARNING: Cannot set status. Response already committed.
- Response already committed; the authentication mechanism must be able to modify buffer size
- Action中使用request、response
- getOutputStream() has already been called for this response错误解决办法!
- getOutputStream() has already been called for this response的解决办法
- getOutputStream() has already been called for this response 解决办法
- getWriter() has already been called for this response 的解决办法
- Tomcat并发
- 【CakePHP1.3】_Optional Configuration
- JAVA SSH面试题整理
- 经常使用的Oracle监控语句
- 用label控件显示金额各式文本
- Action 中 Response already committed 解决办法
- django笔记6
- c++宏定义中 #,#@,##的用法
- agg绘制效率问题请教
- 内网FTP服务器架设简单解析
- 额头、太阳穴、两鬓长痘痘怎么回事?
- AD采集分辨率及精度的解析
- ubuntu下jdk环境变量配置问题
- 2013年人参价格预测