In my Spring MVC project I use Tiles to eliminate any redundant page structure code. As a view renderer, I first chose Thymeleaf because it was descreibed as a primising new kid on the block and pretty easy to use.
Unfortuantely, the integration of Thymeleaf with Tiles depends on deprecated Spring (Tiles2) classes, furthermore the only Thymeleaf forum is almost inactive and questions mostly remain unanswered.
Therefore I want to switch to Freemarker because it has a well established user community and is also supported by Spring. But the configuration of the integrated Spring MVC, Tiles3 and Freemarker is apparently not documented and most examples on the internet are using Tiles in combination of JSP or Freemarker without Tiles, but I cannot find a clear, working integrated example.
I am not very experienced with Spring MVC and confugurations, but I think the following issues must be addressed:
-Loading the Tiles definition file. According to some examples, it can be done using following method in the MvcConfig class:
-Resolving the returning String from a controller method to a Tiles definition:
My first question is whether this Tiles view resolver should be in some way "Freemarker-aware". According to the Tiles documentation, the attribute 'type="freemarker"' should be added to the <definition> tag as well as to the <put-attribute> tags in the Tiles definition XML file, but is it unclear to me what is the effect of that.
Furthermore, the fragments as referenced in the value attribute of those put-attribute tags must be parsed as Freemarker templates instead of JSP. I do not see how this should be configured.
In fact it is unclear to me how the lookup/resolving proces from a Tiles fragment in Spring works. Is the extension .ftl anough for Spring to know that is should look for a Freemarker template?
Some examples lists code fragments like these:
Is this method enough for Spring MVC to load the Freemarker templates from the Tiles definition? How does Spring "know" that a template referenced by Tiles is actually a Freemarker template? There also exists a FreeMarkerViewResolver class which extends UrlBasedViewResolver. But is is unclear to me whether and how we should use this class.
I hope for some clarification and maybe even an integration example
"What you don't know, can't help you"
SCJP (81%), SCWCD (81%), SCJD (354/400), SCBCD (85%)