springboot載入本地靜態資源

2021-10-03 20:58:14 字數 715 閱讀 7996

看了看網上的大部分方法都是自己寫乙個配置類實現webmvcconfigureradapter介面,但是在springboot2.0及spring 5.0 webmvcconfigureradapter已被廢棄,目前找到解決方案就有兩種。

方案1 直接實現webmvcconfigurer

@configuration

public

class

sourceconfiguration

implements

webmvcconfigurer

}

這裡我是請求自己的e盤上的

/div>配置成功

方案2 直接繼承webmvcconfigurationsupport

@configuration

public

class

webmvcconfg

extends

webmvcconfigurationsupport

}其他操作和上方一樣,這裡就不再贅述了。

springboot載入靜態資源

使用springboot寫了簡單的web專案,頁面使用jsp檔案 但是靜態資源js 載入不到,看了下官方文件發現是因為路徑不對 所以專案靜態資源應該配置在根路徑下這四個資料夾中是可以直接訪問到的 meta inf resources,public,resources,static下的資源,對映路徑 ...

Spring Boot 資源載入器

前言參考 原始碼 spring boot 主程式的功能 啟動流程 resourceloader介面,在 spring 中用於載入資源,通過它可以獲取乙個resouce 物件。使用spring的朋友都知道它載入資源的方式由多種,下面就挑兩個常用的繼承resourceloader的介面與實現類說起。de...

載入本地Html檔案

uiwebview webview uiwebview alloc initwithframe cgrectmake 0,0,320,480 autorelease nsstring htmlpath nsbundle quartz2d.html htmlpath htmlpath stringby...