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;