0

Technology : Spring Boot with themeleaf

I'm trying to access the css file placed under src/main/resources/assets/vendor/bootstrap/css/bootstrap.css on my HTML using the following code:

But it is not loading.

Folder Structure :

Resources

--->assets

------>vendor

--------->bootstrap

------------>css

--------------->bootstrap.css

--->code

Can any one help me in this?

2
  • Please add your code. Commented Jul 21, 2017 at 19:24
  • @sirandy: HTML Code <link rel="stylesheet" th:href="@{assets/vendor/bootstrap/css/bootstrap.css}" /> <link rel="stylesheet" th:href="@{assets/vendor/font-awesome/css/font-awesome.css} "/> <link rel="stylesheet" th:href="@{assets/vendor/magnific-popup/magnific-popup.css}" /> <link rel="stylesheet" th:href="@{assets/vendor/bootstrap-datepicker/css/datepicker3.css}" /> Commented Jul 21, 2017 at 19:28

2 Answers 2

1

Here is my spring security config,

    http.
             csrf().disable()
            .authorizeRequests()
            .antMatchers("/home/**", "/**", "/css/**", "/js/**", "/fonts/**", "/images/**", "/public/rest/**","/login*","/signin/**","/signup/**").permitAll()
            .antMatchers("/property/**").authenticated()
            .antMatchers("/welcome/**").authenticated()
            .and()
            .formLogin().loginPage("/login").permitAll()
            .and().httpBasic().disable();

Simply you need this line,

  .antMatchers("/home/**", "/**", "/css/**", "/js/**", "/fonts/**", "/images/**", "/public/rest/**","/login*","/signin/**","/signup/**").permitAll()

But, I would suggest to disable security first and check if everything is working. If that works, then reenable security and try to configure it like shown.

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

Comments

0

From my working project. The resources is under resources/static/js/script.js. And I am accessing it from html like js/script.js. No issue. Probably you are missing static folder. And if you are using spring security, you need to make the resources available.

enter image description here

1 Comment

Yes,I'm using spring security. I moved all the folder to static folder under resources. Still it is not loading. It says Style sheet couldnot be loaded localhost:9000/assets/vendor/bootstrap/css/bootstrap.css

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.