SpringBoot静态资源

1.静态资源映射规则

1.1 webjars

SpringMVC的配置类WebMvcAutoConfiguration中addResourceHandlers添加资源处理
有一个webjars:以jar包的方式引入我们的静态资源

<dependency>
  <groupId>org.webjars</groupId>
  <artifactId>jquery</artifactId>
  <version>3.4.1</version>
</dependency>

1.2 自己的静态资源

resourceProperties配置类中四个路径

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

2.首页

WelcomePageHandlerMapping中
静态资源文件夹下的所有 index.html页面被localhost:8080映射

posted @ 2023-06-29 17:39  lwx_R  阅读(20)  评论(0编辑  收藏  举报