SpringBoot靜態資源處理

2022-02-18 21:38:43 字數 371 閱讀 7291

1.在springboot中,通過以下方式處理靜態資源:

優先順序:resources>static>public

2.模板引擎

只需要使用thymeleaf,匯入相關依賴,將相關資源放入templates包下即可

1

public

static

final string default_prefix = 「classpath:/templates/」;

2public

static

final string default_suffix=".html";

3.首頁配置:靜態資源都用thymeleaf進行管理;@{}

4.頁面國際化:

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...