From 4fa00998bcd4cf2d65f27b4bbbd664926af035ba Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Tue, 2 Jul 2024 16:37:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8B=E8=BD=BD=E6=95=8F?= =?UTF-8?q?=E6=84=9F=E5=AD=97=E6=A8=A1=E6=9D=BF=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcInfoBoardVocabularyController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcInfoBoardVocabularyController.java b/zc-business/src/main/java/com/zc/business/controller/DcInfoBoardVocabularyController.java index 0c031fd1..92a12557 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcInfoBoardVocabularyController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcInfoBoardVocabularyController.java @@ -19,6 +19,8 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.InputStream; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.List; /** @@ -66,10 +68,14 @@ public class DcInfoBoardVocabularyController extends BaseController @ApiOperation("导出敏感词模板") @Log(title = "导出敏感词模板", businessType = BusinessType.EXPORT) @PostMapping("/exportModel") - public void exportModel(HttpServletResponse response) + public void exportModel(HttpServletResponse response) throws Exception { response.setContentType(UniversalEnum.DERIVE_THE_TWO_WAY_REAL_TIME_TRAFFIC_FLOW_OF_THE_WHOLE_SECTION.getValue()); response.setCharacterEncoding(UniversalEnum.LOWERCASE_UTF_8.getValue()); + String fileName = URLEncoder.encode("敏感字模板.xlsx", StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20"); + response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename"); + response.setHeader("Content-disposition", "attachment; filename="+fileName+";filename*=utf-8''"+fileName); + response.setHeader("download-filename", fileName); InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(UniversalEnum.EXPORT_SENSITIVE_WORD_TEMPLATES.getValue()); try { XSSFWorkbook workbook = new XSSFWorkbook(inputStream);