类 FreeMarkerConfigurer

java.lang.Object
cn.taketoday.ui.freemarker.FreeMarkerConfigurationFactory
cn.taketoday.web.view.freemarker.FreeMarkerConfigurer
所有已实现的接口:
cn.taketoday.beans.factory.Aware, cn.taketoday.beans.factory.InitializingBean, cn.taketoday.context.ResourceLoaderAware, FreeMarkerConfig

public class FreeMarkerConfigurer extends cn.taketoday.ui.freemarker.FreeMarkerConfigurationFactory implements FreeMarkerConfig, cn.taketoday.beans.factory.InitializingBean, cn.taketoday.context.ResourceLoaderAware
JavaBean to configure FreeMarker for web usage, via the "configLocation" and/or "freemarkerSettings" and/or "templateLoaderPath" properties. The simplest way to use this class is to specify just a "templateLoaderPath"; you do not need any further configuration then.
 <bean id="freemarkerConfig" class="cn.taketoday.web.view.freemarker.FreeMarkerConfigurer">
   <property name="templateLoaderPath"><value>/WEB-INF/freemarker/</value></property>
 </bean>
This bean must be included in the application context of any application using Framework's FreeMarkerView for web MVC. It exists purely to configure FreeMarker. It is not meant to be referenced by application components but just internally by FreeMarkerView. Implements FreeMarkerConfig to be found by FreeMarkerView without depending on the bean name of the configurer. Each DispatcherServlet can define its own FreeMarkerConfigurer if desired.

Note that you can also refer to a preconfigured FreeMarker Configuration instance, for example one set up by FreeMarkerConfigurationFactoryBean, via the "configuration" property. This allows to share a FreeMarker Configuration for web and email usage, for example. Note: Framework's FreeMarker support requires FreeMarker 2.3 or higher.

从以下版本开始:
4.0
作者:
Darren Davison, Rob Harrop, Harry Yang
另请参阅:
  • FreeMarkerConfigurationFactory.setConfigLocation(cn.taketoday.core.io.Resource)
  • FreeMarkerConfigurationFactory.setFreemarkerSettings(java.util.Properties)
  • FreeMarkerConfigurationFactory.setTemplateLoaderPath(java.lang.String)
  • setConfiguration(freemarker.template.Configuration)
  • FreeMarkerConfigurationFactoryBean
  • FreeMarkerView
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    private freemarker.template.Configuration
     
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    Initialize FreeMarkerConfigurationFactory's Configuration if not overridden by a preconfigured FreeMarker Configuration.
    freemarker.template.Configuration
    Return the Configuration object wrapped by this bean.
    protected void
    postProcessTemplateLoaders(List<freemarker.cache.TemplateLoader> templateLoaders)
    This implementation registers an additional ClassTemplateLoader for the Framework-provided macros, added to the end of the list.
    void
    setConfiguration(freemarker.template.Configuration configuration)
    Set a preconfigured Configuration to use for the FreeMarker web config, e.g. a shared one for web and email usage, set up via FreeMarkerConfigurationFactoryBean.

    从类继承的方法 cn.taketoday.ui.freemarker.FreeMarkerConfigurationFactory

    createConfiguration, getAggregateTemplateLoader, getResourceLoader, getTemplateLoaderForPath, isPreferFileSystemAccess, newConfiguration, postProcessConfiguration, setConfigLocation, setDefaultEncoding, setFreemarkerSettings, setFreemarkerVariables, setPostTemplateLoaders, setPreferFileSystemAccess, setPreTemplateLoaders, setResourceLoader, setTemplateLoaderPath, setTemplateLoaderPaths

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    从接口继承的方法 cn.taketoday.context.ResourceLoaderAware

    setResourceLoader
  • 字段详细资料

    • configuration

      @Nullable private freemarker.template.Configuration configuration
  • 构造器详细资料

    • FreeMarkerConfigurer

      public FreeMarkerConfigurer()
  • 方法详细资料

    • setConfiguration

      public void setConfiguration(freemarker.template.Configuration configuration)
      Set a preconfigured Configuration to use for the FreeMarker web config, e.g. a shared one for web and email usage, set up via FreeMarkerConfigurationFactoryBean. If this is not set, FreeMarkerConfigurationFactory's properties (inherited by this class) have to be specified.
      另请参阅:
      • FreeMarkerConfigurationFactoryBean
    • afterPropertiesSet

      public void afterPropertiesSet() throws IOException, freemarker.template.TemplateException
      Initialize FreeMarkerConfigurationFactory's Configuration if not overridden by a preconfigured FreeMarker Configuration.

      Sets up a ClassTemplateLoader to use for loading Framework macros.

      指定者:
      afterPropertiesSet 在接口中 cn.taketoday.beans.factory.InitializingBean
      抛出:
      IOException
      freemarker.template.TemplateException
      另请参阅:
    • postProcessTemplateLoaders

      protected void postProcessTemplateLoaders(List<freemarker.cache.TemplateLoader> templateLoaders)
      This implementation registers an additional ClassTemplateLoader for the Framework-provided macros, added to the end of the list.
      覆盖:
      postProcessTemplateLoaders 在类中 cn.taketoday.ui.freemarker.FreeMarkerConfigurationFactory
    • getConfiguration

      public freemarker.template.Configuration getConfiguration()
      Return the Configuration object wrapped by this bean.
      指定者:
      getConfiguration 在接口中 FreeMarkerConfig
      返回:
      the FreeMarker Configuration