SpringBoot 配置本地资源映射路径

springboot 1.x配置

@Configuration
public class MyWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
    
        /**
		 * 资源映射路径
		 * addResourceHandler:访问映射路径
		 * addResourceLocations:资源绝对路径
		 */
        registry.addResourceHandler("/image/**").addResourceLocations("file:D:/temp/image/");
    }
}

springboot 2.x配置

/**
 * 资源映射路径
 */
@Configuration
public class MyWebAppConfigurer implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/image/**").addResourceLocations("file:D:/temp-mty/");
    }
}

Mapped URL path 配置的路径,表明设置成功!

0

评论0

本站所有系统都含源码+数据库+导入视频+演示视频+典型代码讲解视频+售后答疑,需要联系客服微信:mtyeducation
没有账号? 注册  忘记密码?
豫ICP备19004322号-2