Created
July 21, 2019 14:50
-
-
Save vector4wang/7580ef584ddd0fc945de52e270db7ddf to your computer and use it in GitHub Desktop.
[springboot 2.x 直接访问静态资源文件] #Springboot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class WebMvcConfig implements WebMvcConfigurer { | |
/** | |
* 添加静态资源文件,外部可以直接访问地址 | |
* | |
* @param registry | |
*/ | |
@Override | |
public void addResourceHandlers(ResourceHandlerRegistry registry) { | |
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment