springboot访问静态资源

@Configuration
public class WebMvcConfiguration extends WebMvcConfigurationSupport {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }
}

templates中的html页面这样引用

<link rel="stylesheet" type="text/css" href="static/css/reset.css"/>
<link rel="stylesheet" type="text/css" href="static/css/reset.css"/>

static 下web中的html这样引用
<script src="../js/jquery-3.3.1.min.js"></script>


好文推荐:https://blog.csdn.net/gebitan505/article/details/70142025

原文地址:https://www.cnblogs.com/yunqing/p/10382010.html