Jayz
Jayz

Reputation: 1174

thymeleaf fragments include

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?

Upvotes: 0

Views: 7542

Answers (2)

ctrlspace
ctrlspace

Reputation: 519

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.

Upvotes: 3

Jayz
Jayz

Reputation: 1174

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.

Upvotes: 1

Related Questions