springboot靜態訪問本地檔案

2021-08-25 17:17:13 字數 356 閱讀 2656

配置檔案中新增靜態對映,需要先把springboot預設的對映加上,用file來進行指定想要訪問的靜態目錄

linux伺服器上以"/"表示跟目錄,windows可以用file: d: 來進行對映

spring:

mvc:

static-path-pattern: /**

resources:

static-locations: classpath:/meta-inf/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/itstyle/, file:/

spring boot 訪問靜態位址

在web開發中,靜態資源的訪問是必不可少的,如 js css 等資源的訪問。spring boot 對靜態資源訪問提供了很好的支援,基本使用預設配置就能滿足開發需求。spring boot 對靜態資源對映提供了預設配置 spring boot 預設將 所有訪問對映到以下目錄 classpath st...

springboot 訪問靜態資源

最近在做springboot 專案遇到靜態資源訪問問題,在這裡記錄下,可以給他人參考避免踩坑 問題點 sprignboot專案建立時預設自動建立靜態資源資料夾resources static和resources templates,預設可直接訪問靜態資源路勁有四類 static,public,res...

spring boot 訪問靜態資源

1.通過從classpath static目錄下 注意必須是static這個目錄。注意,在idea 社群版,第二種方式,無法實現,社群版沒有web外掛程式 無法實現,詳細步驟見 新建乙個工程 spt statics resources,1.pom檔案 org.springframework.boot...