Class SpringTemplateLoader

java.lang.Object
org.springframework.ui.freemarker.SpringTemplateLoader
All Implemented Interfaces:
freemarker.cache.TemplateLoader

public class SpringTemplateLoader extends Object implements freemarker.cache.TemplateLoader
FreeMarker TemplateLoader adapter that loads template files via a Spring ResourceLoader.

Used by FreeMarkerConfigurationFactory for any resource loader path that cannot be resolved to a File.

Since:
14.03.2004
Author:
Juergen Hoeller
See Also:
  • Field Details

    • logger

      protected final org.apache.commons.logging.Log logger
  • Constructor Details

    • SpringTemplateLoader

      public SpringTemplateLoader(ResourceLoader resourceLoader, String templateLoaderPath)
      Create a new SpringTemplateLoader.
      Parameters:
      resourceLoader - the Spring ResourceLoader to use
      templateLoaderPath - the template loader path to use
  • Method Details

    • findTemplateSource

      public @Nullable Object findTemplateSource(String name) throws IOException
      Specified by:
      findTemplateSource in interface freemarker.cache.TemplateLoader
      Throws:
      IOException
    • getReader

      public Reader getReader(Object templateSource, String encoding) throws IOException
      Specified by:
      getReader in interface freemarker.cache.TemplateLoader
      Throws:
      IOException
    • getLastModified

      public long getLastModified(Object templateSource)
      Specified by:
      getLastModified in interface freemarker.cache.TemplateLoader
    • closeTemplateSource

      public void closeTemplateSource(Object templateSource) throws IOException
      Specified by:
      closeTemplateSource in interface freemarker.cache.TemplateLoader
      Throws:
      IOException