哇~我现在只想长长的舒一口气,终于解决了 ~ 记录一下
好,下面开始我的第一个博客,写的不好还请大家见谅~
Spring Boot项目是在官网自动生成的,目录如下:
在红线圈住的“application.properties”文件中进行配置:
application.properties:
spring.mvc.static-path-pattern=/**
web.png-path=D:/temp/picture/
spring.resources.static-locations=classpath:/static/,classpath:/templates/, file:${web.png-path}
其中“web.png-path”表示磁盘中图片存放的路径,“spring.resources.static-location”表示的是静态资源的位置,(下边的是官网给的,和我的目录不同,需要根据自己的项目目录改变一下,官网链接)
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/ # Locations of static resources.
index.html:
在页面用下边的代码来访问,其中“pictureFileName.png”是本地磁盘“D:/temp/picture/”目录下的图片
<img src="/pictureFileName.png" width="500" height="800"></img>