创建stc同级目录pic (如果有需要,可以+二级目录)把需要转的图片文件复制进去
使用utils:PhotoUtils
package com.hrbcft.insurance.utils;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Component
public class PhotoUtils extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/images/**")
.addResourceLocations("file:"+System.getProperty("user.dir")+"/pic/");
}
}
运行项目,发送http://localhost:8801/images/(可能存在的二级目录/)图片名称