使用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;">

你可能感兴趣的:(spring,struts,workflow,Excel,OS)