Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin


For more information on FreeMarker itself, please visit the FreeMarker website.


FreeMarker is very similar to Velocity, as both are template languages that can be used outside of a Servlet container. The framework utilizes FreeMarker because FreeMarker has better the engine includes strong error reporting. However, both are good alternatives to JSP., built-in internationalization and powerful macro libraries.

Support is also included for Velocity templates. For a comparison of Velocity vs FreeMarker see here.

Getting Started

Getting started with FreeMarker is as simple as ensuring all the dependencies are included in your project's classpath. Typically, the only dependency is the {{freemarker.jar}. Other than that, struts-default.xml already configures the FreeMarker Result needed to process your application's templates.


In addition, you can specify a location (directory on your file system) through the templatePath or TemplatePath context variable (in the {{ web.xml)}. If a variable is specified, the content of the directory it points to will be searched first.


As of FreeMarker 2.3.4, an alternative syntax is supported. This alternative syntax is great if you find that your IDE (especially IntelliJ IDEA) makes it difficult to work with the default syntax. You can read more about this syntax here.


You can enable FreeMarker cache mechanism by specifying below options in struts.xml:

  • <constant name="struts.freemarker.templatesCache.updateDelay" value="1800" /> - default update cache interval (5 seconds)
  • <constant name="struts.freemarker.templatesCache" value="true" /> - *DEPRECATED* this option will use a internal ConcurrentHashMap in FreemarkerTemplateEngine but not freemarker native cache

Setting devMode to true will disable cache and updateDelay immediately, but you can explicit specify these constants to enable cache even in devMode, see devMode

Next: Freemarker Tags