首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

使用struts2上载出错getOutputStream() has already been ca

2012-09-09 
使用struts2下载出错getOutputStream() has already been ca报错: java.lang.IllegalStateException: getO

使用struts2下载出错getOutputStream() has already been ca
报错: java.lang.IllegalStateException: getOutputStream() has already been called for this response的错误. Struts方法之间调用引起的。
因为:每个方法都返回的是一个ActionForward对象,而response是ActionForward对象参数,所以就会使response冲突! 故,将最后的return "SUCCESS"改为 return null .不将其交由sturts管理.
如:

/** * 查看图片 * @return * @throws Exception */public String view() throws Exception {    png= workFlowManager.getPngByte(workFlow.getPdID());response.reset();response.setContentType("image/png");response.getOutputStream().write(png.getFileData());response.getOutputStream().flush();response.getOutputStream().close();return null;}

调用页面
<a href="#" onclick="openWin('workFlow!view?workFlow.pdID=<s:property value="#wf.pdID" />','updateorg',700,500);">查看定义图</a>


显示页面

<img src="'workFlow!view?workFlow.pdID=<s:property value="#wf.pdID" />" style="position:absolute;left:0px;top:0px;">

热点排行