SpringBoot09--静态资源的映射规则

一、/webjars/**请求,会去访问classpath:/META-INF/resources/webjars/**的资源。

先说一下webjars:可以将静态资源以jar包的形式导入到项目中。

示例:

1、来到https://www.webjars.org/下,复制jquery的webjars依赖导入

 

 2、导入jquery的webjars后,可以看到它的目录结构

 

 3、访问jquery.js。根据映射规则,应该是:http://localhost:8080/webjars/jquery/3.5.1/jquery.js

二、/**请求。会去访问静态资源文件夹下的资源

静态资源文件夹:

classpath:/META-INF/resources/,

classpath:/resources,

classpath:/static,

classpath:/public,

/

示例:

1、在claspath:/static下新建一个demo.html

 

 2、使用http://localhost:8080/demo.html路径可以访问到该资源

 

三、欢迎页。欢迎页指定命名为index.html,放在静态资源文件夹下,被自动识别

posted @ 2020-08-07 11:34  Ki1lbug  阅读(152)  评论(0)    收藏  举报