在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