open class FreeMarkerConfigurationFactoryBean : FreeMarkerConfigurationFactory, FactoryBean<Configuration>, InitializingBean, ResourceLoaderAware
Factory bean that creates a FreeMarker Configuration and provides it as bean reference. This bean is intended for any kind of usage of FreeMarker in application code, e.g. for generating email content. For web views, FreeMarkerConfigurer is used to set up a FreeMarkerConfigurationFactory. The simplest way to use this class is to specify just a "templateLoaderPath"; you do not need any further configuration then. For example, in a web application context:
<bean id="freemarkerConfiguration" class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean"> <property name="templateLoaderPath" value="/WEB-INF/freemarker/"/> </bean> See the base class FreeMarkerConfigurationFactory for configuration details.
Note: Spring's FreeMarker support requires FreeMarker 2.3 or higher.
Author
Darren Davison
Since
03.03.2004
See Also
#setConfigLocation#setFreemarkerSettings#setTemplateLoaderPathorg.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer
FreeMarkerConfigurationFactoryBean()
Factory bean that creates a FreeMarker Configuration and provides it as bean reference. This bean is intended for any kind of usage of FreeMarker in application code, e.g. for generating email content. For web views, FreeMarkerConfigurer is used to set up a FreeMarkerConfigurationFactory. The simplest way to use this class is to specify just a "templateLoaderPath"; you do not need any further configuration then. For example, in a web application context: See the base class FreeMarkerConfigurationFactory for configuration details.
Note: Spring's FreeMarker support requires FreeMarker 2.3 or higher. |
open fun afterPropertiesSet(): Unit |
|
open fun getObject(): Configuration |
|
open fun getObjectType(): Class<out Configuration> |
|
open fun isSingleton(): Boolean |
open fun createConfiguration(): Configuration
Prepare the FreeMarker Configuration and return it. |
|
open fun setConfigLocation(resource: Resource): Unit
Set the location of the FreeMarker config file. Alternatively, you can specify all setting locally. |
|
open fun setDefaultEncoding(defaultEncoding: String): Unit
Set the default encoding for the FreeMarker configuration. If not specified, FreeMarker will use the platform file encoding. Used for template rendering unless there is an explicit encoding specified for the rendering process (for example, on Spring's FreeMarkerView). |
|
open fun setFreemarkerSettings(settings: Properties): Unit
Set properties that contain well-known FreeMarker keys which will be passed to FreeMarker's |
|
open fun setFreemarkerVariables(variables: MutableMap<String, Any>): Unit
Set a Map that contains well-known FreeMarker objects which will be passed to FreeMarker's |
|
open fun setPostTemplateLoaders(vararg postTemplateLoaders: TemplateLoader): Unit
Set a List of The TemplateLoader specified here will be registered after the default template loaders that this factory registers (such as loaders for specified "templateLoaderPaths" or any loaders registered in |
|
open fun setPreTemplateLoaders(vararg preTemplateLoaders: TemplateLoader): Unit
Set a List of The TemplateLoader specified here will be registered before the default template loaders that this factory registers (such as loaders for specified "templateLoaderPaths" or any loaders registered in |
|
open fun setPreferFileSystemAccess(preferFileSystemAccess: Boolean): Unit
Set whether to prefer file system access for template loading. File system access enables hot detection of template changes. If this is enabled, FreeMarkerConfigurationFactory will try to resolve the specified "templateLoaderPath" as file system resource (which will work for expanded class path resources and ServletContext resources too). Default is "true". Turn this off to always load via SpringTemplateLoader (i.e. as stream, without hot detection of template changes), which might be necessary if some of your templates reside in an expanded classes directory while others reside in jar files. |
|
open fun setResourceLoader(resourceLoader: ResourceLoader): Unit
Set the Spring ResourceLoader to use for loading FreeMarker template files. The default is DefaultResourceLoader. Will get overridden by the ApplicationContext if running in a context. |
|
open fun setTemplateLoaderPath(templateLoaderPath: String): Unit
Set the Freemarker template loader path via a Spring resource location. See the "templateLoaderPaths" property for details on path handling. |
|
open fun setTemplateLoaderPaths(vararg templateLoaderPaths: String): Unit
Set multiple Freemarker template loader paths via Spring resource locations. When populated via a String, standard URLs like "file:" and "classpath:" pseudo URLs are supported, as understood by ResourceEditor. Allows for relative paths when running in an ApplicationContext. Will define a path for the default FreeMarker template loader. If a specified resource cannot be resolved to a To enforce the use of SpringTemplateLoader, i.e. to not resolve a path as file system resource in any case, turn off the "preferFileSystemAccess" flag. See the latter's javadoc for details. If you wish to specify your own list of TemplateLoaders, do not set this property and instead use |