日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁技術文章
文章詳情頁

SpringBoot如何通過webjars管理靜態資源文件夾

瀏覽:101日期:2023-04-12 18:44:13

WebMvcAutoConfiguration

添加資源映射:

public void addResourceHandlers(ResourceHandlerRegistry registry) { if (!this.resourceProperties.isAddMappings()) {logger.debug('Default resource handling disabled'); } else {Duration cachePeriod = this.resourceProperties.getCache().getPeriod();CacheControl cacheControl = this.resourceProperties.getCache().getCachecontrol().toHttpCacheControl();if (!registry.hasMappingForPattern('/webjars/**')) { this.customizeResourceHandlerRegistration(registry.addResourceHandler(new String[]{'/webjars/**'}).addResourceLocations(new String[]{'classpath:/META-INF/resources/webjars/'}).setCachePeriod(this.getSeconds(cachePeriod)).setCacheControl(cacheControl));}String staticPathPattern = this.mvcProperties.getStaticPathPattern();if (!registry.hasMappingForPattern(staticPathPattern)) { this.customizeResourceHandlerRegistration(registry.addResourceHandler(new String[]{staticPathPattern}).addResourceLocations(WebMvcAutoConfiguration.getResourceLocations(this.resourceProperties.getStaticLocations())).setCachePeriod(this.getSeconds(cachePeriod)).setCacheControl(cacheControl));} } }

所有'/webjars/**'路徑 , 都去類路徑下 classpath: /META-INF/resources/webjars/ 找資源, 所以就是

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

能訪問

/META-INF/resources/webjars/jquery/3.5.1/jquery.js 路徑的文件

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

什么是webjar?

搜索webjar, 可以將jquery用pom引入:

SpringBoot如何通過webjars管理靜態資源文件夾

引入, 正好對應這個映射:

SpringBoot如何通過webjars管理靜態資源文件夾

結果是的:

SpringBoot如何通過webjars管理靜態資源文件夾

2) springboot對靜態資源的映射規則:

看代碼:

還是

WebMvcAutoConfiguration的這個方法

public void addResourceHandlers(ResourceHandlerRegistry registry) { if (!this.resourceProperties.isAddMappings()) { logger.debug('Default resource handling disabled'); } else { Duration cachePeriod = this.resourceProperties.getCache().getPeriod(); CacheControl cacheControl = this.resourceProperties.getCache().getCachecontrol().toHttpCacheControl(); if (!registry.hasMappingForPattern('/webjars/**')) { this.customizeResourceHandlerRegistration(registry.addResourceHandler(new String[]{'/webjars/**'}).addResourceLocations(new String[]{'classpath:/META-INF/resources/webjars/'}).setCachePeriod(this.getSeconds(cachePeriod)).setCacheControl(cacheControl)); } String staticPathPattern = this.mvcProperties.getStaticPathPattern(); if (!registry.hasMappingForPattern(staticPathPattern)) { this.customizeResourceHandlerRegistration(registry.addResourceHandler(new String[]{staticPathPattern}).addResourceLocations(WebMvcAutoConfiguration.getResourceLocations(this.resourceProperties.getStaticLocations())).setCachePeriod(this.getSeconds(cachePeriod)).setCacheControl(cacheControl)); } }}

進去:

WebMvcProperties

private String staticPathPattern; private final WebMvcProperties.Async async; private final WebMvcProperties.Servlet servlet; private final WebMvcProperties.View view; private final WebMvcProperties.Contentnegotiation contentnegotiation; private final WebMvcProperties.Pathmatch pathmatch; public WebMvcProperties() { this.localeResolver = WebMvcProperties.LocaleResolver.ACCEPT_HEADER; this.format = new WebMvcProperties.Format(); this.dispatchTraceRequest = false; this.dispatchOptionsRequest = true; this.ignoreDefaultModelOnRedirect = true; this.publishRequestHandledEvents = true; this.throwExceptionIfNoHandlerFound = false; this.logResolvedException = false; this.staticPathPattern = '/**'; this.async = new WebMvcProperties.Async(); this.servlet = new WebMvcProperties.Servlet(); this.view = new WebMvcProperties.View(); this.contentnegotiation = new WebMvcProperties.Contentnegotiation(); this.pathmatch = new WebMvcProperties.Pathmatch(); }

addResourceLocations(WebMvcAutoConfiguration.getResourceLocations(this.resourceProperties.getStaticLocations())) 這里添加了資源的位置

public class ResourceProperties { private static final String[] CLASSPATH_RESOURCE_LOCATIONS = new String[]{'classpath:/META-INF/resources/', 'classpath:/resources/', 'classpath:/static/', 'classpath:/public/'}; private String[] staticLocations; private boolean addMappings; private final ResourceProperties.Chain chain; private final ResourceProperties.Cache cache; public ResourceProperties() { this.staticLocations = CLASSPATH_RESOURCE_LOCATIONS; this.addMappings = true; this.chain = new ResourceProperties.Chain(); this.cache = new ResourceProperties.Cache(); }

'/**'訪問當前項目的任何資源, (靜態資源的文件夾) ,如果沒人處理,會默認去以下幾個文件路徑下找[/code]復制代碼 代碼如下:// 靜態資源文件夾, 這幾個都可以存放靜態資源:

classpath:/META-INF/resources/classpath:/resources/'classpath:/static/'classpath:/public/

例如 localhost:8080/a/b.js , 可以到 /META-INF/resources/a/b.js 找

SpringBoot如何通過webjars管理靜態資源文件夾

SpringBoot如何通過webjars管理靜態資源文件夾

或者:

/resources/a/b.js找:

SpringBoot如何通過webjars管理靜態資源文件夾

SpringBoot如何通過webjars管理靜態資源文件夾

或者類路徑下/static/a/b.js找:

SpringBoot如何通過webjars管理靜態資源文件夾

SpringBoot如何通過webjars管理靜態資源文件夾

或者/public/a/b.js下找

SpringBoot如何通過webjars管理靜態資源文件夾

SpringBoot如何通過webjars管理靜態資源文件夾

3)歡迎頁面: 靜態資源文件夾下的所有index.html頁面: 被 /**映射

http://localhost:8080/ 會到以上靜態資源文件夾中找index.html頁面

源碼有變化,我沒明白回頭再看

結果:

SpringBoot如何通過webjars管理靜態資源文件夾

路徑:

SpringBoot如何通過webjars管理靜態資源文件夾

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Spring
相關文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
色爱av综合网| 亚洲精品乱码| 国产精品www.| 欧美有码在线| 国产精品中文字幕制服诱惑| 欧美精品国产白浆久久久久| 日本中文字幕一区二区视频| 天堂va在线高清一区| 久久国产日本精品| 亚洲区第一页| 亚洲精品少妇| 国产精品亚洲人成在99www| 日本视频在线一区| 国产欧美一区二区三区精品观看| 99久久婷婷| 亚洲开心激情| 欧美国产视频| 亚洲a在线视频| 日韩精品91亚洲二区在线观看| 久久精品 人人爱| 精品亚洲美女网站| 亚洲一区国产| 免费在线日韩av| 99精品国产一区二区三区| 免费国产自线拍一欧美视频| 日本不卡高清视频| 国产精品色婷婷在线观看| 蜜桃精品视频| 婷婷六月综合| 亚洲欧洲日韩精品在线| 91亚洲一区| 蜜桃av一区二区| 成人影视亚洲图片在线| 丝袜美腿亚洲一区二区图片| 国产伦精品一区二区三区视频| 国产一区二区三区成人欧美日韩在线观看| 欧美日韩一区二区三区视频播放| 亚洲精品成人一区| 日本韩国欧美超级黄在线观看| 日韩高清电影免费| 黄色成人在线网址| 91嫩草亚洲精品| 青草综合视频| 欧美精品一卡| 99精品小视频| 精品久久91| 国产一区 二区| 中文字幕一区二区三区四区久久| 日韩高清欧美| 精品国产日韩欧美精品国产欧美日韩一区二区三区 | 另类激情亚洲| 成人羞羞视频播放网站| 精品一区二区三区亚洲| 69精品国产久热在线观看| 久久高清一区| 在线日韩视频| 日韩成人高清| 在线天堂资源www在线污| 国产精久久一区二区| 青草国产精品| 97精品资源在线观看| 欧美视频久久| 久久精品999| 久久av导航| 超碰成人av| 日韩精品欧美激情一区二区| 国产精品亚洲一区二区三区在线观看| 精品国产不卡一区二区| 精品视频一区二区三区四区五区 | 欧美日韩中文一区二区| 91精品一区国产高清在线gif| 久久夜夜操妹子| 亚洲特级毛片| 日韩在线一区二区| 日本欧美在线看| 欧美日韩亚洲一区三区| 国产精品毛片视频| 黄在线观看免费网站ktv| 日韩在线观看一区| 99免费精品| 美女久久网站| 久久国内精品自在自线400部| 欧美激情在线精品一区二区三区| 国产一区二区视频在线看| 日韩中文在线电影| 国产精品日韩| 国产精品高潮呻吟久久久久| 欧美天堂视频| 性一交一乱一区二区洋洋av| 日本视频在线一区| 群体交乱之放荡娇妻一区二区| 免费视频久久| 成人一区不卡| 综合亚洲视频| 国内不卡的一区二区三区中文字幕| 98精品久久久久久久| 免费久久99精品国产| 国产精品伊人| 黄色亚洲精品| 日韩欧美在线中字| 清纯唯美亚洲综合一区| 欧美~级网站不卡| 欧美激情视频一区二区三区免费 | 国产视频一区免费看| 国产日韩欧美三级| 亚洲专区欧美专区| 欧美激情麻豆| 亚洲精品乱码| 亚洲激情社区| 久久婷婷丁香| 夜夜嗨一区二区三区| 136国产福利精品导航网址| 亚洲91视频| 性欧美69xoxoxoxo| 亚洲精品乱码| 噜噜噜久久亚洲精品国产品小说| 欧美交a欧美精品喷水| 一区二区三区四区在线观看国产日韩| 福利视频一区| 国产精品久久久久久久久免费高清 | 好看的av在线不卡观看| 激情久久99| 国产精品v一区二区三区| 日本不卡一区二区| 日韩在线一二三区| 美女久久一区| 亚洲人成在线影院| 日本亚州欧洲精品不卡| 亚洲毛片网站| 日本国产欧美| 国产精品手机在线播放| 日本不卡一二三区黄网| 亚洲理论在线| 国产高清亚洲| 精品视频一区二区三区在线观看 | 欧美国产免费| 日韩高清中文字幕一区二区| 日韩欧美在线中字| 欧美+日本+国产+在线a∨观看| 欧美1级日本1级| 亚洲区第一页| 国产精久久一区二区| 91免费精品| 亚洲精品1区| 日韩高清一区在线| 日韩成人午夜精品| 国产精品美女在线观看直播| 精品国产乱码久久久| 亚洲精品.com| 亚洲人成精品久久久| 久久亚洲精品中文字幕| 久久久亚洲一区| 日韩精品1区2区3区| 国产一区二区三区精品在线观看| 久久国产影院| 欧美天堂一区二区| 久久夜夜操妹子| 欧美一级一区| 欧美日韩国产高清| 国产福利亚洲| 91精品国产乱码久久久久久久| 日韩三级一区| 久久久777| 麻豆精品新av中文字幕| 亚洲国产一区二区在线观看| 欧美日韩午夜电影网| 久久久久免费av| 麻豆精品新av中文字幕| 麻豆精品91| 人人精品亚洲| 久久国产精品免费精品3p| 在线一区免费观看| 岛国av免费在线观看| 久久国产免费看| 美女久久网站| 秋霞影院一区二区三区| 国产精品久久久久久模特 | 激情综合自拍| 国产福利资源一区| 日韩福利视频导航| 男女男精品网站| 欧美91福利在线观看| 日韩久久精品| 久久精品亚洲| 国产精品久久久久av蜜臀| 91久久中文| 九色精品91| 欧美1级日本1级| 欧美aa国产视频| 91精品国产成人观看| a日韩av网址| 成人午夜精品| 91精品国产乱码久久久久久久| 综合日韩av| 裤袜国产欧美精品一区| 国产一区二区三区四区二区| 精品国产三区在线| 国产一区一一区高清不卡| 精品五月天堂| 日韩精品欧美|