0

I'm having difficulty importing my CSS files with spring 4

First i tried this in index.html

<link  href="../../resources/css/bootstrap.min.css" rel="stylesheet">

Eclipse did not acknowledge any errors, but when I run the application the css does not load on the page

After searching i did this

registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");

And in index.html I left it like that, and it worked

<link  href="resources/css/bootstrap.min.css" rel="stylesheet">

But the eclipse says there is an error look this

my classpath

statics

@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 is the correct way to import CSS and JS and spring 4?

2)Why the first way did not work? using ../../

3)How to import without eclipse accuse error?

thanks guys^^

2
  • try using <link href="/resources/css/bootstrap.min.css" rel="stylesheet"> Commented Apr 24, 2017 at 10:06
  • Here you can find my answer with the same problem: stackoverflow.com/a/53125816/9918701 Commented Nov 2, 2018 at 21:09

1 Answer 1

0

To My previous knowledge and errors make sure you are defining the correct directory and adding the right links. Hope that helped if not I am sorry.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.