springboot访问静态资源404

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

当时引入了模板引擎 static中得静态资源说啥都访问不到,后来加入了配置就好了

 

 

spring:
mvc:
static-path-pattern: /static/**
resources:
static-locations: classpath:/static


WebMvcAutoConfiguration中
这个是设置得请求方式,put,delete,get啥的

 

 获取我们得资源路径

 

 springboot得静态资源路径配置

ResourceProperties这个类
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = new String[]{"classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"};








posted @ 2021-07-13 12:35  三号小玩家  阅读(1277)  评论(0编辑  收藏  举报
Title
三号小玩家的 Mail: 17612457115@163.com, 联系QQ: 1359720840 微信: QQ1359720840