天天看點

springboot通過URL直接擷取圖檔

第一步:

確定是web項目

映射請求到圖檔路徑下

相對路徑:registry.addResourceHandler("/static/**").addResourceLocations("classpath:/templates/static/");

絕對路徑: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直接擷取圖檔

繼續閱讀