天天看點

Springboot 靜态資源通路路徑配置1. 預設路徑2. 自定義路徑

1. 預設路徑

Springboot 預設提供的靜态資源目錄位置需位于 classpath 下,目錄名為

  1. classpath:/static
  2. classpath:/public
  3. classpath:/resources
  4. classpath:/META-INF/resources

2. 自定義路徑

# 靜态檔案請求比對方式
spring.mvc.static-path-pattern=/test/**

# 修改預設的靜态資源目錄,多個用 逗号 隔開

spring.resources.static-locations=classpath:/static/,classpath:/test/

# 加上自定義的資源路徑後,預設的靜态資源路徑将失效,是以,如果預設的也要用到,預設的也需要加上。
           

繼續閱讀