• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Spring4, Tiles and Freemarker integration problems

Ranch Hand
Posts: 111
PHP Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am also facing the same issue. Without type"freemarker" it doesn't recognise the file at all. With type"freemarker" an error is displayed that freemarker renderer is not registered.
    Bookmark Topic Watch Topic
  • New Topic