Commit 792ebaa8619718a13bf4abb64baf2cf242d6a7a7
1 parent
0b398542
模板下载存在兼容问题修改
Showing
1 changed file
with
10 additions
and
5 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/costfee/CostFeeController.java
| ... | ... | @@ -114,10 +114,15 @@ public class CostFeeController{ |
| 114 | 114 | // 设置下载响应头 |
| 115 | 115 | response.reset(); |
| 116 | 116 | response.setContentType(EXCEL_MIME_TYPE); |
| 117 | - // response.setCharacterEncoding("UTF-8"); | |
| 118 | - String encodedName = URLEncoder.encode(downloadFileName, "UTF-8").replaceAll("\\+", "%20"); | |
| 119 | - response.setHeader("Content-Disposition", "attachment;filename=" + encodedName); | |
| 120 | - response.setHeader("Cache-Control", "no-store"); // 禁止缓存 | |
| 117 | + // response.setCharacterEncoding("UTF-8"); | |
| 118 | + String encodedName = URLEncoder.encode(downloadFileName, "UTF-8"); | |
| 119 | + // 标准文件名编码(Chrome / Edge / Firefox 全兼容) | |
| 120 | + response.setHeader("Content-Disposition", "attachment;filename*=UTF-8''" + encodedName); | |
| 121 | + // 浏览器缓存配置(必须) | |
| 122 | + response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); | |
| 123 | + response.setHeader("Pragma", "no-cache"); | |
| 124 | + response.setHeader("Expires", "0"); | |
| 125 | + | |
| 121 | 126 | |
| 122 | 127 | try (InputStream in = resource.getInputStream(); |
| 123 | 128 | XSSFWorkbook workbook = new XSSFWorkbook(in); |
| ... | ... | @@ -203,7 +208,7 @@ public class CostFeeController{ |
| 203 | 208 | } |
| 204 | 209 | String unit = cell.getStringCellValue(); |
| 205 | 210 | // 默认赋值【第一个单位】,你可以根据业务改成其他值 |
| 206 | - if (!StringUtils.isEmpty(unit)) { | |
| 211 | + if (!StringUtils.isEmpty(unit) && options.size() > 3) { | |
| 207 | 212 | cell.setCellValue(options.get(2)); |
| 208 | 213 | } |
| 209 | 214 | } | ... | ... |