SpringBoot 对静态资源的映射规则

一、所有 /webjars/** ,都去 classpath:/META-INF/resources/webjars/ 找资源

webjars:以jar包的方式引入静态资源,如下:引入 jquery 。( http://www.webjars.org/ )

<!‐‐引入jquery‐webjar‐‐>在访问的时候只需要写webjars下面资源的名称即可
<dependency>
  <groupId>org.webjars</groupId>
  <artifactId>jquery</artifactId>
  <version>3.3.1</version>
</dependency>

 

通过此 localhost:8080/webjars/jquery/3.3.1/jquery.js 可以访问到 jquery

二、"/**" 访问当前项目的任何资源,都去(静态资源的文件夹)找映射

"classpath:/META‐INF/resources/",
"classpath:/resources/",
"classpath:/static/",
"classpath:/public/"
"/":当前项目的根路径

localhost:8080/abc === 去静态资源文件夹里面找 abc

三、欢迎页; 静态资源文件夹下的所有 index.html 页面;被"/**"映射;

四、所有的 **/favicon.ico 都是在静态资源文件下找

猜你喜欢

转载自www.cnblogs.com/fangwu/p/8921968.html
今日推荐