SpringBoot 中静态资源设置

Posted starudream

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SpringBoot 中静态资源设置相关的知识,希望对你有一定的参考价值。

不建议在配置文件 application.properties 中配置 spring.mvc.static-path-patternspring.resources.static-locations 进行修改。

建议实现 WebMvcConfigurer 接口并重写 addResourceHandlers 方法。

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry
        .addResourceHandler("/upload/**")
        .addResourceLocations("file:/usr/data/upload");
}

以上是关于SpringBoot 中静态资源设置的主要内容,如果未能解决你的问题,请参考以下文章