If you have configure the spring resource handlers but didn’t display correctly on the browser, try check the following configuration.
Web @Configuration
This sample code show that missing line @EnabledWebMVC, therefore the resource handler is not activated.
@Configuration @ComponentScan(basePackageClasses = Application.class) class WebMvcConfig extends WebMvcConfigurerAdapter { private static final String VIEWS = "/WEB-INF/views/"; private static final String RESOURCES_LOCATION = "/resources/"; private static final String RESOURCES_HANDLER = RESOURCES_LOCATION + "**"; @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry .addResourceHandler(RESOURCES_HANDLER) .addResourceLocations(RESOURCES_LOCATION); } // code omitted }
Make sure you have annotated @EnableWebMvc, refresh browser and you’ll see the result.
Troubleshooting spring resource handlers