<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 一、spring boot靜態資源 ### 靜態資源目錄 SpringBoot默認配置下,提供了以下幾個靜態資源目錄: ~~~ /static: classpath:/static/ /public: classpath:/public/ /resources: classpath:/resources/ /META-INF/resources:classpath:/META-INF/resources/ ~~~ 當然,可以通過spring.resources.static-locations配置指定靜態文件的位置。**但是要特別注意,一旦自己指定了靜態資源目錄,系統默認的靜態資源目錄就會失效。所以系統默認的就已經足夠使用了,盡量不要自定義。** ~~~ #配置靜態資源 spring: resources: #指定靜態資源目錄 static-locations: classpath:/mystatic/ ~~~ ### favicon.ico圖標 如果在配置的靜態資源目錄中有favicon.ico文件,SpringBoot會自動將其設置為應用圖標。 ### 歡迎頁面 SpringBoot支持靜態和模板歡迎頁,它首先在靜態資源目錄查看index.html文件做為首頁,若未找到則查找index模板。 ![](https://img.kancloud.cn/26/ad/26adb6b454081cc998f5942160f896fc_323x177.png) ![](https://img.kancloud.cn/27/ce/27cee3c098b8a06b6b4c424a582c1276_442x269.png) ## 二、使用WebJars管理css&js **為什么使用 WebJars?** 顯而易見,因為簡單。但不僅是依賴這么簡單: * 清晰的管理 web 依賴 * 通過 Maven, Gradle 等項目管理工具就可以下載 web 依賴 * 解決 web 組件中傳遞依賴的問題以及版本問題 * 頁面依賴的版本自動檢測功能 WebJars是將這些通用的Web前端資源打包成Java的Jar包,然后借助Maven工具對其管理,保證這些Web資源版本唯一性,升級也比較容易。關于webjars資源,有一個專門的網站[https://www.webjars.org/](https://www.webjars.org/),我們可以到這個網站上找到自己需要的資源,在自己的工程中添加入maven依賴,即可直接使用這些資源了。 ### 1.pom中引入依賴 我們可以從WebJars官方查看maven依賴,如下圖 這里寫圖片描述 ![](https://box.kancloud.cn/36c6ae71536e0699e290eb6a76d0b68c_1887x786.png) 例如:將jquery引入pom文件中 ~~~ <dependency> <groupId>org.webjars</groupId> <artifactId>jquery</artifactId> <version>1.12.4</version> </dependency> ~~~ ### 2.訪問引入的js文件 SpringBoot將webjar中路徑`/webjars/**`的訪問重定向到項目的`classpath:/META-INF/resources/webjars/*`。例如:在html內訪問靜態資源可以使用目錄`/webjars/jquery/1.12.4/jquery.js`. ~~~ <script src="/webjars/jquery/1.12.4/jquery.min.js "></script> ~~~ ## 三、自動檢測依賴的版本 如果使用 Spring 4.2 以上的版本,并且加入 webjars-locator 組件,就不需要在 html 添加依賴的時候填寫版本。 ~~~ <dependency> <groupId>org.webjars</groupId> <artifactId>webjars-locator</artifactId> <version>0.30</version> </dependency> ~~~ 引入 webjars-locator 值后可以省略版本號: ~~~ <script src="/webjars/jquery/jquery.min.js"></script> ~~~ 注意:只能去掉版本號
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看