import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class ResourceConfigAdapter implements WebMvcConfigurer {
@Value("${linux.download.path}")
private String linuxDir;
@Value("${win.download.path}")
private String winDir;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
String os = System.getProperty("os.name");
if (os.toLowerCase().startsWith("win")) {
registry.addResourceHandler("/images/**").
addResourceLocations("file:"+winDir);
}else{
registry.addResourceHandler("/images/**").
addResourceLocations("file:"+linuxDir);
}
}
}