IntelliJ Spring Boot project can't find my CSS files with Thymeleaf

前端 未结 2 618
眼角桃花
眼角桃花 2021-01-22 05:40

I\'m new to Spring Boot and my problem is that I have Spring Boot project and I am intending to view my HTML pages with Thymeleaf but Spring can\'t resolve my JavaScript and CSS

2条回答
  •  执笔经年
    2021-01-22 05:49

    I have found that Spring automatically searches for: /resources/.
    So what I did was removed all the pre-directories by using find all.

    So, in my case what used to be for example: /static/css/style.css & /templates/index.html

    became: /css/style.css & /index.html

    Now the question remains how does Spring boot know what folder to look in without you defining it: Spring looks at the extension. When spring boot sees .html, it looks for it in a folder called /templates.

提交回复
热议问题