本文使用的是Springboot官方推荐的thymeleaf(一种页面模板技术)

首先在pom文件加依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
  • Springboot项目中resources文件包含 templatesstatic等文件夹

  • 其中templates存放html界面,static存放css、js等文件

  • 想要读取图片,在static文件下创建images文件夹,放入图片。

  • 测试时可以在浏览器地址栏输入localhost:80880/images/xxx.jpg,此时网页可以显示即路径正确。

  • 在html界面调用时src="images/xxx.png/jpg"
    Springboot项目中 前端展示本地图片

此时即可成功调用。

相关文章:

  • 2021-10-11
  • 2021-12-05
  • 2021-12-16
  • 2021-07-19
  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
  • 2020-12-25
猜你喜欢
  • 2021-08-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2021-09-21
  • 2021-09-14
相关资源
相似解决方案