例如要访问的本地路径是D盘下的PersonalHomePage目录的某个图片
1 import org.springframework.context.annotation.Configuration; 2 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 3 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 4 5 /** 6 * 资源映射路径 7 */ 8 @Configuration 9 public class MyWebAppConfigurer implements WebMvcConfigurer { 10 @Override 11 public void addResourceHandlers(ResourceHandlerRegistry registry) { 12 registry.addResourceHandler("/PersonalHomePage/**").addResourceLocations("file:D:/PersonalHomePage/"); 13 } 14 }
http://192.168.1.120:8083/PersonalHomePage/t6.jpg
标签:PersonalHomePage,springboot,tomcat,路径,springframework,文件夹,org,import,annotation From: https://www.cnblogs.com/woju/p/16706949.html