SpringBoot 對靜態資源的映射規則
阿新 • • 發佈:2018-04-24
cti meta classpath pen 圖片 分享 引入 index -i
一、所有 /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 都是在靜態資源文件下找
SpringBoot 對靜態資源的映射規則