2021年1月12日 星期二

[SpringBoot 1.5] 引入webjars和靜態頁面

 1 /webjars/**, 都去classpath:/Meta-INF/resources/webjars/找資源

webjars:以jar包的方式引入靜態資源

可以到網站 https://www.webjars.org/ 找尋需要用到的jar包

比方說我們找到Jquery3.3.1版本的Maven設置

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

然後我們將其貼到SpingBoot專案的pom.xml當中

重新download jar檔案

我們啟動服務後, 就可以在 

http://localhost:8080/webjars/jquery/3.3.1/jquery.js

找到完整的檔案

2 靜態資源可以被找到的路徑如下

"classpath:/META-INF/resources/",
"classpath:/resources/",
"classpath:/static/",
"classpath:/public/"
"/":當前項目的根路徑

3歡迎頁面

也就是index.html頁面

在所有靜態資源下的index.html頁面都會被找到

當你有此頁面的時候

只要輸入 http://localhost:8080/

他會自動導入到首頁



沒有留言:

張貼留言

[leetcode] [KMP] KMP

ABCDABD... ABCDABF... 簡單的說, 傳統解兩字串匹配部分 可能會來個雙迴圈, 哀個比對, 當不匹配的時候, 會將下方列再後移1位 然後不匹配再後移 然而 如果像上放已經有4個屬於匹配的字串, 她就應該直接往後移四位來匹配, 而不是只移動1位 隱藏的思維是, 當...