spring boot靜態資源路徑配置

2021-09-22 10:17:51 字數 975 閱讀 5672

spring:

mvc:

static-path-pattern: /**

resources:

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

#the directory of adc resource located

resource.path.prefix: d:/share/data/space

這裡遇到的問題是,是使用 sts,自動新增相應配置項,帶有「-」,導致配置多個路徑的時候,配置不生效

spring:

mvc:

static-path-pattern: /**

resources:

static-locations:

- classpath:/meta-inf/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:$

#the directory of adc resource located

adc.resource.path.prefix: d:/share/data/adcspace

但是單獨配置,如下,是可以讀取到的,還需要進一步了解機制

spring:

mvc:

static-path-pattern: /**

resources:

static-locations:

- file:$

#the directory of adc resource located

adc.resource.path.prefix: d:/share/data/adcspace

spring boot 靜態資源

springboot中,預設的靜態資源路徑有 配置在resourceproperties類中 private static final string classpath resource locations 優先順序 靜態資源路徑 例如 webmvcautoconfiguration自動裝配類中,可...

springboot載入靜態資源

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

Spring Boot 靜態資源處理

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