静态资源路径映射优化 (#172)

优化后 获取静态资源路径和操作系统无关
pull/174/head
j.yao.SUSE 2019-11-04 11:31:23 +08:00 committed by elunez
parent 58575378db
commit 9882cb97a7
1 changed files with 2 additions and 2 deletions

View File

@ -35,8 +35,8 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
String avatarUtl = "file:" + avatar.replace("\\","/");
String pathUtl = "file:" + path.replace("\\","/");
String avatarUtl = Paths.get(avatar).normalize().toUri().toASCIIString();
String pathUtl = Paths.get(path).normalize().toUri().toASCIIString();
registry.addResourceHandler("/avatar/**").addResourceLocations(avatarUtl).setCachePeriod(0);
registry.addResourceHandler("/file/**").addResourceLocations(pathUtl).setCachePeriod(0);
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0);