Problem Spring MVC + Maven + Bootstrap

0

Good morning. I'm trying to put bootstrap in the index of my application but I'm not getting it, the index does not read the CSS. I searched the internet and from what I understood, the css should stay within the following structure, src / main / webapp / resources.css /

<!-- Bootstrap core CSS -->
<link href="/resources.css/bootstrap.min.css" rel="stylesheet">

The structure is like this;

    
asked by anonymous 06.03.2017 / 16:48

1 answer

1

You need to configure Spring to serve your static resources. This can be done programmatically or via XML.

Java configuration class

@Configuration
public class SpringConfig extends WebMvcConfigurerAdapter {  

   ...

   @Override
   public void addResourceHandlers(ResourceHandlerRegistry registry) {
       registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
   }

   @Override
   public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
       configurer.enable();
   }
}

Servlet.xml

<mvc:resources mapping="/resources/**" location="/resources/"/>
    
06.03.2017 / 17:26