I'm encountering issues when trying to import my CSS files using spring 4
Initially, I attempted the following in index.html:
<link href="../../resources/css/bootstrap.min.css" rel="stylesheet">
Although Eclipse did not detect any errors, the css was not loading on the webpage when I ran the application.
After some research, I made the following change:
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
For index.html, I modified it as follows, and this resolved the issue:
<link href="resources/css/bootstrap.min.css" rel="stylesheet">
However, Eclipse flagged an error which can be seen here: look at this
You can also check out my classpath
Here is a snippet of the code:
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/*.html").addResourceLocations("/WEB-INF/html/");
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
super.addResourceHandlers(registry);
}
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController( "/" ).setViewName( "forward:/index.html" );
}
1) What's the correct method for importing CSS and JS in spring 4?
2) Why did the initial method with ../../ fail to work?
3) How can I import without Eclipse reporting errors?
Thank you all!^^