激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類(lèi)導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語(yǔ)言|JavaScript|易語(yǔ)言|vb.net|

香港云服务器
服務(wù)器之家 - 編程語(yǔ)言 - Java教程 - SpringBoot靜態(tài)資源目錄訪問(wèn)

SpringBoot靜態(tài)資源目錄訪問(wèn)

2021-06-26 13:41staHuri Java教程

今天小編就為大家分享一篇關(guān)于SpringBoot靜態(tài)資源目錄訪問(wèn),小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧

靜態(tài)資源配置

創(chuàng)建一個(gè)staticconfig 繼承 webmvcconfigureradapter

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package com.huifer.blog.config;
import org.springframework.context.annotation.configuration;
import org.springframework.web.servlet.config.annotation.resourcehandlerregistry;
import org.springframework.web.servlet.config.annotation.webmvcconfigureradapter;
/**
 * 描述:
 * 靜態(tài)文件配置
 * @author huifer
 * @date 2019-01-01
 */
@configuration
public class staticconfig extends webmvcconfigureradapter {
  public void addresourcehandlers(resourcehandlerregistry registry) {
    registry.addresourcehandler("/js/**").addresourcelocations("classpath:/static/js/");
    registry.addresourcehandler("/css/**").addresourcelocations("classpath:/static/css/");
    registry.addresourcehandler("/fonts/**").addresourcelocations("classpath:/static/fonts/");
    registry.addresourcehandler("/images/**").addresourcelocations("classpath:/static/images/");
    super.addresourcehandlers(registry);
  }
}

SpringBoot靜態(tài)資源目錄訪問(wèn)

翻看源碼發(fā)實(shí)現(xiàn)了webmvcconfigurer 故而修改

SpringBoot靜態(tài)資源目錄訪問(wèn)

創(chuàng)建一個(gè)staticconfig 實(shí)現(xiàn) webmvcconfigurer

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package com.huifer.blog.config;
import org.springframework.context.annotation.configuration;
import org.springframework.web.servlet.config.annotation.resourcehandlerregistry;
import org.springframework.web.servlet.config.annotation.webmvcconfigurer;
/**
 * 描述:
 * 靜態(tài)文件配置
 * @author huifer
 * @date 2019-01-01
 */
@configuration
public class staticconfig implements webmvcconfigurer {
  public void addresourcehandlers(resourcehandlerregistry registry) {
    registry.addresourcehandler("/js/**").addresourcelocations("classpath:/static/js/");
    registry.addresourcehandler("/css/**").addresourcelocations("classpath:/static/css/");
    registry.addresourcehandler("/fonts/**").addresourcelocations("classpath:/static/fonts/");
    registry.addresourcehandler("/images/**").addresourcelocations("classpath:/static/images/");
//    super.addresourcehandlers(registry);
  }
}

修改pom 文件

?
1
2
3
4
5
6
<resources>
      <resource>
<directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>

以上三種方案都可以訪問(wèn)到 static目錄

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)服務(wù)器之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接

原文鏈接:https://blog.csdn.net/staHuri/article/details/85561243

延伸 · 閱讀

精彩推薦
554
主站蜘蛛池模板: 久久国产精品久久久久久久久久 | 欧美成人精品不卡视频在线观看 | 福利免费在线观看 | av在线影片| 久国产 | 国产精品久久久久久婷婷天堂 | 久综合| 欧美一a一片一级一片 | 久久靖品 | 久久91亚洲精品久久91综合 | 国产免费一区二区三区最新不卡 | 久久亚洲精品久久国产一区二区 | 成人午夜激情视频 | 色综合久久99 | 国产精选在线 | 久久老司机 | 免费国产在线精品 | 特色一级黄色片 | 草久视频在线观看 | 日韩毛片网 | 色综合久久久久综合99 | 久草在线看片 | 精国产品一区二区三区四季综 | 亚洲国产网址 | 一区二区三区在线播放视频 | 黄色二区三区 | 成人在线免费看 | 国产毛片视频 | 毛片在哪看 | 色综合777| 爽毛片 | 国产免费视频一区二区裸体 | 国产精品久久久久久久久久东京 | 黄色片网站在线免费观看 | 国产亚洲精品网站 | 色妞欧美 | 日本在线视| 亚洲精品久久久久久久久久 | av在线免费观看不卡 | 色视频一区二区 | 久久草在线视频国产 |