类 FreeMarkerConfigurer
- java.lang.Object
- org.springframework.ui.freemarker.FreeMarkerConfigurationFactory
- org.springframework.web.reactive.result.view.freemarker.FreeMarkerConfigurer
- 所有已实现的接口:
Aware
,InitializingBean
,ResourceLoaderAware
,FreeMarkerConfig
public class FreeMarkerConfigurer extends FreeMarkerConfigurationFactory implements FreeMarkerConfig, InitializingBean, ResourceLoaderAware
Configures 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" (e.g. "classpath:templates"); you do not need any further configuration then.This bean must be included in the application context of any application using
FreeMarkerView
. It exists purely to configure FreeMarker. It is not meant to be referenced by application components but just internally byFreeMarkerView
. ImplementsFreeMarkerConfig
to be found byFreeMarkerView
without depending on the bean name of the configurer.Note that you can also refer to a pre-configured FreeMarker Configuration instance via the "configuration" property. This allows to share a FreeMarker Configuration for web and email usage for example.
This configurer registers a template loader for this package, allowing to reference the "spring.ftl" macro library contained in this package:
<#import "/spring.ftl" as spring/> <@spring.bind "person.age"/> age is ${spring.status.value}
Note: Spring's FreeMarker support requires FreeMarker 2.3 or higher.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev
字段概要
从类继承的字段 org.springframework.ui.freemarker.FreeMarkerConfigurationFactory
logger
构造器概要
构造器 构造器 说明 FreeMarkerConfigurer()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Initialize FreeMarkerConfigurationFactory's Configuration if not overridden by a pre-configured FreeMarker Configuration.freemarker.template.Configuration
getConfiguration()
Return the Configuration object wrapped by this bean.protected void
postProcessTemplateLoaders(List<freemarker.cache.TemplateLoader> templateLoaders)
This implementation registers an additional ClassTemplateLoader for the Spring-provided macros, added to the end of the list.void
setConfiguration(freemarker.template.Configuration configuration)
Set a pre-configured Configuration to use for the FreeMarker web config, e.g. a shared one for web and email usage.从类继承的方法 org.springframework.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
从接口继承的方法 org.springframework.context.ResourceLoaderAware
setResourceLoader
构造器详细资料
FreeMarkerConfigurer
public FreeMarkerConfigurer()
方法详细资料
setConfiguration
public void setConfiguration(freemarker.template.Configuration configuration)
Set a pre-configured Configuration to use for the FreeMarker web config, e.g. a shared one for web and email usage. If this is not set, FreeMarkerConfigurationFactory's properties (inherited by this class) have to be specified.
afterPropertiesSet
public void afterPropertiesSet() throws IOException, freemarker.template.TemplateException
Initialize FreeMarkerConfigurationFactory's Configuration if not overridden by a pre-configured FreeMarker Configuration.Sets up a ClassTemplateLoader to use for loading Spring macros.
- 指定者:
afterPropertiesSet
在接口中InitializingBean
- 抛出:
IOException
freemarker.template.TemplateException
- 另请参阅:
FreeMarkerConfigurationFactory.createConfiguration()
,setConfiguration(freemarker.template.Configuration)
postProcessTemplateLoaders
protected void postProcessTemplateLoaders(List<freemarker.cache.TemplateLoader> templateLoaders)
This implementation registers an additional ClassTemplateLoader for the Spring-provided macros, added to the end of the list.- 覆盖:
postProcessTemplateLoaders
在类中FreeMarkerConfigurationFactory
- 参数:
templateLoaders
- the current List of TemplateLoader instances, to be modified by a subclass- 另请参阅:
FreeMarkerConfigurationFactory.createConfiguration()
,FreeMarkerConfigurationFactory.setPostTemplateLoaders(freemarker.cache.TemplateLoader...)
getConfiguration
public freemarker.template.Configuration getConfiguration()
Return the Configuration object wrapped by this bean.- 指定者:
getConfiguration
在接口中FreeMarkerConfig
- 返回:
- the FreeMarker Configuration