bind CSS in a Spring MVC project

0

Look closely at the image;

Itriedtoputitlikethisonthepage;

<!--LatestcompiledandminifiedCSS--><linkrel="stylesheet" type="text/css"  href="#">#

but did not get the CSS settings.

======== UPDATE ========================================================

I've tried it that way too;

<link rel="stylesheet"  href="resources.css/style.css/>
<link rel="stylesheet"  href="#">#                    
asked by anonymous 13.04.2016 / 14:18

1 answer

1

In your Spring MVC configuration class that extends the WebMvcConfigurerAdapter , method addResourceHandlers should be overwritten by doing this:

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

The first parameter "/resources/**" tells you which URL will access the static resources (css, js, img ...), the second parameter informs which folder is the resources "/views/resources/"

Example:

    
13.04.2016 / 14:45