springboot 静态资源配置
Posted 骑着毛驴追火车
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot 静态资源配置相关的知识,希望对你有一定的参考价值。
package com.linmingliang.myblog.interceptor;
import org.springframework.stereotype.Component;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
/**
* @Author: lml
* @Date: 2018/6/1 16:32
* @Description:
*/
@Component
public class MyWebAppConfigurer extends WebMvcConfigurationSupport {
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
super.addResourceHandlers(registry);
registry.addResourceHandler("/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX+"/static/");
registry.addResourceHandler("/upload/**").addResourceLocations("file:D:/mydreams/myblog/upload/");
}
}
以上是关于springboot 静态资源配置的主要内容,如果未能解决你的问题,请参考以下文章