spring boot access images in resources folder

Solutions on MaxInterview for spring boot access images in resources folder by the best coders in the world

showing results for - "spring boot access images in resources folder"
Ashley
15 Oct 2017
1@SpringBootApplication
2public class MainApplication implements WebMvcConfigurer {
3
4    private static Logger logger = LoggerFactory.getLogger(MainApplication.class.getName());
5
6    @Override
7    public void addResourceHandlers(ResourceHandlerRegistry registry) {
8
9        // Register resource handler for images
10        registry.addResourceHandler("/images/**").addResourceLocations("/WEB-INF/images/")
11                .setCacheControl(CacheControl.maxAge(2, TimeUnit.HOURS).cachePublic());
12    }
13
14    public static void main(String[] args) {
15        SpringApplication.run(MainApplication.class, args);
16    }
17}