GroupExchangeNetworkFeedBack groupExchangeNetworkFeedBack = groupExchangeNetworkFeedBackBiz.getGroupExchangNetworkFeedBackById(feedBackId); String attachName = groupExchangeNetworkFeedBack.getAttachment(); String attachUrl = groupExchangeNetworkFeedBack.getAttachmentUrl(); // 取得HttpServletResponse对象 HttpServletResponse response = ServletActionContext.getResponse(); //获取web应用程序在服务器上的路径需要访问ServletAPI ServletContext context = ServletActionContext.getServletContext(); // 通知浏览器以下载方式打开文件 // response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(exportFileName, "utf-8")); response.setHeader("content-disposition", "attachment;filename=" + new String(attachName.getBytes("gbk"), "ISO8859-1")); // String realPath = context.getRealPath(attachUrl); // 构造子节输入流 InputStream is = new FileInputStream(attachUrl + "/" + attachName); // 构造子节输出流 OutputStream os = response.getOutputStream(); byte[] b = new byte[1024]; int len = 0; while ((len = is.read(b)) > 0) { os.write(b, 0, len); } is.close(); os.close(); return null;