Is it possible to configure Thymeleaf/Spring application to serve templates and static resources from the same directory (either via configuration or custom view resolver)?
I'm using Thymeleaf just for localization of the templates and rest of the page logic is handled by Angular JS. I have it working with templates and static content separated but this will be a big project and I want to use recommended structure where all files related to one page are located in the same "package".
I'm looking for 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
Thank you for any suggestions.
This is feasible, however the risk you have is that you will also expose the html template itself as a static resource which is not a good idea. Can I instead recommend having 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With