From 18050e272e34946cd325f0edc80e5d80d9ebd8e1 Mon Sep 17 00:00:00 2001 From: yanghx Date: Fri, 18 Jan 2019 15:13:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8D=95=E4=B8=AAjar?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8B=E8=BD=BD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/manage/FileControl.java | 22 +++++++++++++++++++ src/main/resources/vm/manage/filemanage.vm | 14 ++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/main/java/cn/jiangzeyin/controller/manage/FileControl.java b/src/main/java/cn/jiangzeyin/controller/manage/FileControl.java index 55f6bcdd2..9ff503f1d 100644 --- a/src/main/java/cn/jiangzeyin/controller/manage/FileControl.java +++ b/src/main/java/cn/jiangzeyin/controller/manage/FileControl.java @@ -3,6 +3,7 @@ package cn.jiangzeyin.controller.manage; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.CharsetUtil; +import cn.hutool.extra.servlet.ServletUtil; import cn.jiangzeyin.common.DefaultSystemLog; import cn.jiangzeyin.common.JsonMessage; import cn.jiangzeyin.common.PageUtil; @@ -157,6 +158,27 @@ public class FileControl extends BaseController { return JsonMessage.getString(200, "上传成功"); } + /** + * 下载文件 + * + * @return File + */ + @RequestMapping(value = "download") + @ResponseBody + public String download() { + String id = getParameter("id"); + String filename = getParameter("filename"); + try { + ProjectInfoModel pim = manageService.getProjectInfo(id); + String path = pim.getLib() + filename; + File file = new File(path); + ServletUtil.write(getResponse(), file); + } catch (Exception e) { + DefaultSystemLog.ERROR().error("下载文件异常", e); + } + return "下载失败。请刷新页面后重试"; + } + @RequestMapping(value = "clear") @ResponseBody diff --git a/src/main/resources/vm/manage/filemanage.vm b/src/main/resources/vm/manage/filemanage.vm index 963b05d1d..99d62c1a2 100644 --- a/src/main/resources/vm/manage/filemanage.vm +++ b/src/main/resources/vm/manage/filemanage.vm @@ -33,6 +33,7 @@ ## 删除按钮