From 1a1dd38da058e0e4b14695708d0687c4a1b0c37a Mon Sep 17 00:00:00 2001 From: sgjj <995959152@qq.com> Date: Wed, 25 Sep 2019 16:20:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/net/mingsoft/config/WebConfig.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/mingsoft/config/WebConfig.java b/src/main/java/net/mingsoft/config/WebConfig.java index d806353b..5fd8fbba 100644 --- a/src/main/java/net/mingsoft/config/WebConfig.java +++ b/src/main/java/net/mingsoft/config/WebConfig.java @@ -32,6 +32,16 @@ import net.mingsoft.basic.util.BasicUtil; @Configuration public class WebConfig implements WebMvcConfigurer { + /** + * 上传路径 + */ + @Value("${ms.upload.path}") + private String uploadFloderPath; + /** + * 上传路径映射 + */ + @Value("${ms.upload.mapping}") + private String uploadMapping; @Bean public ActionInterceptor actionInterceptor() { return new ActionInterceptor(); @@ -62,7 +72,13 @@ public class WebConfig implements WebMvcConfigurer { registry.addResourceHandler("/app/**").addResourceLocations("/app/","file:app/", "classpath:/app/"); registry.addResourceHandler("/static/**","/**").addResourceLocations("/static/","file:static/","classpath:/static/"); registry.addResourceHandler("/api/**").addResourceLocations("/api/","file:api/", "classpath:/api/"); - + if(uploadFloderPath.startsWith("file:")){ + //如果指定了绝对路径,上传的文件都映射到uploadMapping下 + registry.addResourceHandler(uploadMapping).addResourceLocations(uploadFloderPath+ File.separator + //映射其他路径文件 + //,file:F://images + ); + } } /** * druidServlet注册