导出功能Content-Disposition字段需要暴露在外问题修改

This commit is contained in:
qiaoqinzheng 2023-10-23 14:12:56 +08:00
parent fd7a0113e6
commit a35c41e4e3
2 changed files with 10 additions and 4 deletions

View File

@ -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();
}

View File

@ -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());