spring boot 图片映射配置

@Configuration
public class WebConfigurer implements WebMvcConfigurer {
    @Value("${SavePath.ProfilePhoto}")
    private String ProfilePhotoSavePath;   //图标图片存储路径

    @Value("${SavePath.ProfilePhotoMapper}")
    private String ProfilePhotoMapperPath;   //图标映射路径

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //addResourceHandler映射路径、addResourceLocations真实存放路径
        registry.addResourceHandler(ProfilePhotoMapperPath+"**")
                .addResourceLocations("file:" + ProfilePhotoSavePath);
    }
}


版权声明:本文为weixin_42727978原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。