mirror of https://github.com/elunez/eladmin
优化静态资源路径映射
parent
a6d128dac2
commit
5c8f4b5e46
|
@ -7,6 +7,8 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* WebMvcConfigurer
|
||||
*
|
||||
|
@ -35,8 +37,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);
|
||||
|
|
Loading…
Reference in New Issue