0

I have a Spring Boot Application. I am trying to load to my HTML file a CSS file, but probably I am doing something wrong. In Spring MVC Project I've done something like this:

In HTML file I added the following line:

<link href="<c:url value="/resources/css/style.css" />" rel="stylesheet">

And in mvc-dispatcher-servlet.xml I added following code:

<mvc:resources mapping="/resources/**" location="/resources/"
               cache-period="31556926"/>
<mvc:annotation-driven />

And everything worked perfect.

Now I'm using thymeleaf templating language and load my CSS file like that:

<link rel="stylesheet" type="text/css" th:href="@{/assets/css/style.css}" />

My project files hierarchy is following:

Files Hierarchy

In current project I don't have WEB-INF directory so I don't have such a files like mvc-dispatcher-servlet.xml or web.xml so I don't know if I should or where I should paste that code with resources mapping. Im completely new to Spring so I apologise for my lack of knowledge.

Any tips and solutions will be much appreciated.

Bohuslav Burghardt
  • 33,626
  • 7
  • 114
  • 109
  • 3
    Place your `assets` folder in `src/main/resources/static` or `src/main/resources/public` or `src/main/resources/resources`. See [this guide](https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot) for details. – Bohuslav Burghardt Nov 11 '15 at 11:04
  • Wow it worked! Thank you so much! I had no idea it can be so easy... – Krzysiek Zienkiewicz Nov 11 '15 at 11:33

0 Answers0