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