Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between static and templates folder under resources in a springboot & thymeleaf project?

I'm new to thymeleaf and springboot.

I create a springboot project with thymeleaf in IntelliJ IDEA with "New Project"->"Spring Initalizr".

Then I get a project whose structure looks like below.

demo
  |+-src/main
  |    +-java
  |    +-resources
  |         static
  |         templates
  |         application.properties
  |-pom.xml

The question is what should I put in static and templates under resources? What's the difference between them?

I guess the .html files that have thymeleaf attributes should be put in templates. How about static html, css and js?

Thanks.

like image 220
Kanjie Lu Avatar asked Jan 21 '17 14:01

Kanjie Lu


1 Answers

templates folder is a place where you put all the thymeleaf templates. It is a default directory (by default spring will look inside for any templates).

static folder is used for serving web static content, all the css, js, html etc. (also default folder search by spring) http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-static-content

like image 73
pezetem Avatar answered Oct 18 '22 22:10

pezetem