dw 2 주 전
부모
커밋
9e115aa7a9
1개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. 10
    1
      src/main/java/com/th/demo/tools/Tools.java

+ 10
- 1
src/main/java/com/th/demo/tools/Tools.java 파일 보기

@@ -138,12 +138,21 @@ public class Tools {
138 138
 
139 139
 
140 140
 
141
+
142
+
141 143
     ///123423456
142 144
     public static OutputStream getExportOutStream(String filename, HttpServletResponse response) {
143 145
         OutputStream out = null;
144 146
         try {
145
-            response.setContentType("application/vnd.ms-excel");
147
+            // 使用正确的 xlsx Content-Type
148
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
146 149
             response.setHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes("UTF-8"), "ISO8859-1"));
150
+            // 禁用缓存
151
+            response.setHeader("Pragma", "no-cache");
152
+            response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
153
+            response.setHeader("Expires", "0");
154
+            // 设置缓冲区大小为大文件优化
155
+            response.setBufferSize(8192); // 8KB buffer
147 156
             out = response.getOutputStream();
148 157
         } catch (Exception ex) {
149 158
             ex.printStackTrace();

Loading…
취소
저장