From 6f6fb8e00b8fcbeb21dcfccb0819ee3440d50888 Mon Sep 17 00:00:00 2001 From: "liu.zixi" Date: Mon, 24 Nov 2025 14:05:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AF=BE=E7=A8=8B=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=AD=A3=20=E7=BB=A7=E7=BB=AD?= =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E6=AD=A3=E6=96=87=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../course/service/impl/CoursePageServiceImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/course/service/impl/CoursePageServiceImpl.java b/servers/boe-server-all/src/main/java/com/xboe/module/course/service/impl/CoursePageServiceImpl.java index 9577190f..ab3f575a 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/module/course/service/impl/CoursePageServiceImpl.java +++ b/servers/boe-server-all/src/main/java/com/xboe/module/course/service/impl/CoursePageServiceImpl.java @@ -30,6 +30,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.OutputStream; +import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -286,7 +287,13 @@ public class CoursePageServiceImpl implements ICoursePageService { try (OutputStream out = response.getOutputStream()) { response.setContentType("application/octet-stream"); String fileName = "课程列表.xlsx"; - response.setHeader("Content-disposition", "attachment;filename=" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1)); + + // 对文件名进行 URL 编码(用于 filename*) + String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()).replaceAll("\\+", "%20"); + + // 设置 Content-Disposition,同时提供 filename 和 filename* + response.setHeader("Content-Disposition", + "attachment; filename=\"" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1) + "\"; filename*=UTF-8''" + encodedFileName); ExportsExcelSenderUtil.exportDynamic(exportMap, dataList, out, null); } catch (Exception e) { throw new AppException("导出课程列表发生异常", e);