1. 程式人生 > >springboot檔案虛擬路徑對映

springboot檔案虛擬路徑對映

在application.properties配置檔案中配置:

spring.http.multipart.location= D:/
spring.mvc.static-path-pattern=/**
spring.resources.static-locations=  classpath:/,  file:${spring.http.multipart.location}

表示:讀取檔案時從我們的磁碟D中讀取檔案,例如:我們資料庫中存取的檔案路徑為:

/2018/06/21//danPicture/cefb656f8cf542968107ca51e15c4ee5-1529540867019.png

那麼在頁面中展示的圖片的路徑實際上是我們本機電腦的路徑:

D:/2018/06/21//danPicture/cefb656f8cf542968107ca51e15c4ee5-1529540867019.png

就是說會自動幫我們做一個拼接的操作!!!!