String contenttype = rs.getString("contentType"); String filename = rs.getString("fileName"); response.setContentType(contenttype); response.setHeader("Content-disposition","attachment;filename=" + filename.replace('"', ' ')); java.io.InputStream instream = rs.getBinaryStream("fileData"); byte[] b = new byte[1000]; while (instream.read(b) > 0) { try { response.getOutputStream().write(b); } catch(Exception e) {} } try { response.getOutputStream().flush(); } catch(Exception e) {}
通常,它应该允许调用response.getOutputStream()任意次。我认为您同时呼叫response.getOutputStream()和response.getWriter()。
response.getOutputStream()
response.getWriter()
请检查您是否正在呼叫response.getWriter()任何地方,或者该请求是否正在写入的JSP中进行response.getWriter()。