Skip to content

Instantly share code, notes, and snippets.

@vector4wang
Created July 21, 2019 14:50
Show Gist options
  • Save vector4wang/7580ef584ddd0fc945de52e270db7ddf to your computer and use it in GitHub Desktop.
Save vector4wang/7580ef584ddd0fc945de52e270db7ddf to your computer and use it in GitHub Desktop.
[springboot 2.x 直接访问静态资源文件] #Springboot
@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