日期:2014-05-18 浏览次数:20813 次
try { response.setContentType("text/plain:charset=GBK"); response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); byte[] bytes = logDetails.getBytes(); ServletOutputStream outStream = response.getOutputStream(); outStream.write(bytes); outStream.flush(); outStream.close(); } catch (Exception e) { log.debug("保存文件出错: " + e.getMessage()); }
------解决方案--------------------
同意楼上,response直接读出数据,再设置response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
就可以保存了。