From e3670ca4d7a9bf01f2b4a959d4676020377fea9f Mon Sep 17 00:00:00 2001 From: liyongde <1419499670@qq.com> Date: Wed, 23 Aug 2023 15:06:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9B=BE=E7=89=87=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/nl/config/ConfigurerAdapter.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 nladmin-system/nlsso-server/src/main/java/org/nl/config/ConfigurerAdapter.java diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/config/ConfigurerAdapter.java b/nladmin-system/nlsso-server/src/main/java/org/nl/config/ConfigurerAdapter.java new file mode 100644 index 0000000..826645e --- /dev/null +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/config/ConfigurerAdapter.java @@ -0,0 +1,33 @@ +package org.nl.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * WebMvcConfigurer + * + * @author Zheng Jie + * @date 2018-11-30 + */ +@Configuration +@EnableWebMvc +public class ConfigurerAdapter implements WebMvcConfigurer { + /** 文件配置 */ + private final FileProperties properties; + + public ConfigurerAdapter(FileProperties properties) { + this.properties = properties; + } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + FileProperties.ElPath path = properties.getPath(); + String avatarUtl = "file:" + path.getAvatar().replace("\\","/"); + String pathUtl = "file:" + path.getPath().replace("\\","/"); + registry.addResourceHandler("/avatar/**").addResourceLocations(avatarUtl).setCachePeriod(0); + registry.addResourceHandler("/file/**").addResourceLocations(pathUtl).setCachePeriod(0); + registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0); + } +}