第一步:

配置配置文件填加 classpath:/image/

springboot通过URL直接获取图片

 第二步:

映射请求到图片路径下
registry.addResourceHandler("/image/**").addResourceLocations("file:" + SystemAPI.filePath);

注意:SystemAPI.filePath为要访问的文件夹路径

springboot通过URL直接获取图片

整体代码如图

springboot通过URL直接获取图片

实现以上两步便可以通过URL(http://192.168.2.105:5005/image/430425196910236722.jpg)请求到SystemAPI.filPath路径下的图片 

springboot通过URL直接获取图片

相关文章:

  • 2021-05-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
  • 2021-06-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-15
  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
  • 2021-10-25
相关资源
相似解决方案