Question

I keep getting "Error resolving template "fragments/common", template might not exist or might not be accessible by any of the configured Template Resolvers". The path of common.html file is correct, fragments->common.html. My folder structure:

-- WEB-INF

---- templates

------ fragments

-------- common.html

------ index.html

Any help or pointers?

Was it helpful?

Solution 2

Alright, I found the problem. Wrong syntax, the error message says it all. I was using common.html, the template name included in include statement is incorrect.

OTHER TIPS

I know I'm late to the party but I thought I'd share what I'm doing which to me seemed somewhat easier.

I use a java config class to configure thymeleaf and I use the template alias to make it easier:

resolver.addTemplateAlias("footerTemplate","templates/footer");

Then I can simple do something like:

<div th:include="footerTemplate :: copy"></div>

assuming you have your suffix and prefix setup correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top