From c1c2596883cd00b46fcfc783ab8c2af62e138f01 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 02 三月 2023 13:55:37 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/helper/WebHelper.java | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/lf/server/helper/WebHelper.java b/src/main/java/com/lf/server/helper/WebHelper.java index 57a4a1b..96b8e6e 100644 --- a/src/main/java/com/lf/server/helper/WebHelper.java +++ b/src/main/java/com/lf/server/helper/WebHelper.java @@ -298,20 +298,28 @@ /** * 涓嬭浇鏂囦欢 + */ + public static void download(String file, String fileName, HttpServletResponse res) throws Exception { + download(file, fileName, res); + } + + /** + * 涓嬭浇鏂囦欢 * * @param file 鏂囦欢 * @param fileName 鏂囦欢鍚� * @param res 鍝嶅簲 * @throws Exception 寮傚父 */ - public static void download(String file, String fileName, HttpServletResponse res) throws Exception { + public static void download(String file, String fileName, boolean inline, HttpServletResponse res) throws Exception { if (StringHelper.isEmpty(fileName)) { fileName = StringHelper.YMDHMS2_FORMAT.format(new Date()); } fileName = URLEncoder.encode(fileName, "UTF-8").replace("+", "%20"); + String dispose = inline ? "inline" : "attachment"; // 璁剧疆鍝嶅簲澶翠腑鏂囦欢鐨勪笅杞芥柟寮忎负闄勪欢鏂瑰紡锛屼互鍙婅缃枃浠跺悕 - res.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + fileName); + res.setHeader("Content-Disposition", dispose + "; filename*=UTF-8''" + fileName); // 璁剧疆鍝嶅簲澶寸殑缂栫爜鏍煎紡涓� UTF-8 res.setCharacterEncoding("UTF-8"); -- Gitblit v1.9.3