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

就是说会自动帮我们做一个拼接的操作!!!!

猜你喜欢

转载自blog.csdn.net/qiuqiu1628480502/article/details/80758882