From a35c41e4e3fe4a9fdc2544c89948a2ae143f41ce Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Mon, 23 Oct 2023 14:12:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BDContent-Dis?= =?UTF-8?q?position=E5=AD=97=E6=AE=B5=E9=9C=80=E8=A6=81=E6=9A=B4=E9=9C=B2?= =?UTF-8?q?=E5=9C=A8=E5=A4=96=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/jeecg/common/util/ExportUtil.java | 12 ++++++++---- .../jeecg/modules/service/impl/GammaServiceImpl.java | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java index 1db130bd..f1f29914 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java @@ -29,7 +29,8 @@ public class ExportUtil { response.setCharacterEncoding(UTF_8); response.setContentType("application/vnd.ms-excel"); String name = URLEncoder.encode(fileName, UTF_8); - response.setHeader("Content-disposition", "attachment;filename=" + name); + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); + response.setHeader("Content-Disposition", "attachment;filename=" + name); return response.getOutputStream(); } @@ -37,7 +38,8 @@ public class ExportUtil { response.setCharacterEncoding(UTF_8); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); String name = URLEncoder.encode(fileName, UTF_8); - response.setHeader("Content-disposition", "attachment;filename=" + name); + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); + response.setHeader("Content-Disposition", "attachment;filename=" + name); return response.getOutputStream(); } @@ -53,7 +55,8 @@ public class ExportUtil { response.setCharacterEncoding(UTF_8); response.setContentType("application/octet-stream"); String name = URLEncoder.encode(fileName, UTF_8); - response.setHeader("Content-disposition", "attachment;filename=" + name); + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); + response.setHeader("Content-Disposition", "attachment;filename=" + name); return response.getWriter(); } @@ -61,7 +64,8 @@ public class ExportUtil { response.setCharacterEncoding(UTF_8); response.setContentType("text/html"); String name = URLEncoder.encode(fileName, UTF_8); - response.setHeader("Content-disposition", "attachment;filename=" + name); + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); + response.setHeader("Content-Disposition", "attachment;filename=" + name); return response.getWriter(); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index 121b085a..4d93ad02 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -4491,6 +4491,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi //设置响应类型 response.setContentType("application/octet-stream"); //解决中文不能生成文件 + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode(txtFileName,"UTF-8")); fos = response.getOutputStream(); fos.write(strBuild.toString().getBytes()); @@ -4643,6 +4644,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi //设置响应类型 response.setContentType("application/octet-stream"); //解决中文不能生成文件 + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode(phdFileName,"UTF-8")); fos = response.getOutputStream(); fos.write(spectrum.getBytes());