For a jsp page mapping I use a bin (configuration class @Configuration) @Bean

public UrlBasedViewResolver setupViewResolver() { UrlBasedViewResolver resolver = new UrlBasedViewResolver(); resolver.setPrefix("/WEB-INF/pages/"); resolver.setSuffix(".jsp"); resolver.setViewClass(JstlView.class); resolver.setOrder(1); return resolver; } 

What bin is needed for mapping images in resources, to display them on the jsp page and how to access the image on the page?

1 answer 1

Here it is necessary not to declare a bin, but to configure the resource handler. Example:

 @Configuration @EnableWebMvc public class MvcConfig extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry .addResourceHandler("/resources/**") .addResourceLocations("/resources/"); } } 

Read more and in English: http://www.baeldung.com/spring-mvc-static-resources