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.


Struts2 itself The framework utilizes FreeMarker templates for its own tags because the engine can load templates from the classpath (unlike JSPs), has includes strong error reporting, built-in internationalization and powerful macro libraries.


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


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