Thymeleaf templates and static resources in the same directory

Is it possible to configure the Thymeleaf / Spring application to serve templates and static resources from the same directory (either using configuration or using custom permission)?

I use Thymeleaf only to localize the templates, and the rest of the page logic is handled by Angular JS. I have work with templates and static content, but it will be a big project, and I want to use the recommended structure, where all files related to one page are in the same “package”.

I am looking for a structure that looks like this:

└── src └── main └── java └── HelloController.java └── LoginController.java └──resources └──templates └──hello └──hello.html (dynamic thymeleaf template) └──hello.js (static resource) └──hello.css (static resource) └──login └──login.html └──login.js └──login.css └──webapp └──WEB-INF └──web.xml 

Thanks for any suggestions.

+5
source share
1 answer

It is possible, however, the risk that you have is that you also expose the html template itself as a static resource, which is not a good idea. Can I instead recommend a parallel hierarchy for static resources along these lines:

 src main resources static js hello hello.js login login.js css hello hello.css login login.css templates hello hello.html login login.html 
+1
source

Source: https://habr.com/ru/post/1204703/


All Articles