org.springframework.web.servlet.view.freemarker
Class FreeMarkerConfigurer
java.lang.Object
org.springframework.ui.freemarker.FreeMarkerConfigurationFactory
org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer
- All Implemented Interfaces:
- FreeMarkerConfig, InitializingBean, ResourceLoaderAware
- public class FreeMarkerConfigurer
- extends FreeMarkerConfigurationFactory
- implements FreeMarkerConfig, InitializingBean, 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="org.springframework.web.servlet.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 Spring'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 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: Spring's FreeMarker support requires FreeMarker 2.3 or higher.
- Since:
- 3/3/2004
- Version:
- $Id: FreeMarkerConfigurer.java,v 1.2 2004/04/22 07:58:26 jhoeller Exp $
- Author:
- Darren Davison
- See Also:
FreeMarkerConfigurationFactory.setConfigLocation(org.springframework.core.io.Resource)
,
FreeMarkerConfigurationFactory.setFreemarkerSettings(java.util.Properties)
,
FreeMarkerConfigurationFactory.setTemplateLoaderPath(java.lang.String)
,
setConfiguration(freemarker.template.Configuration)
,
FreeMarkerConfigurationFactoryBean
,
FreeMarkerView
Method Summary |
void |
afterPropertiesSet()
Initialize FreeMarkerConfigurationFactory's Configuration
if not overridden by a preconfigured FreeMarker Configuation. |
freemarker.template.Configuration |
getConfiguration()
Return the FreeMarker Configuration object for the current
web application context.
|
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.
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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.
- See Also:
FreeMarkerConfigurationFactoryBean
afterPropertiesSet
public void afterPropertiesSet()
throws java.io.IOException,
freemarker.template.TemplateException
- Initialize FreeMarkerConfigurationFactory's Configuration
if not overridden by a preconfigured FreeMarker Configuation.
- Specified by:
afterPropertiesSet
in interface InitializingBean
- Throws:
java.io.IOException
freemarker.template.TemplateException
- See Also:
FreeMarkerConfigurationFactory.createConfiguration()
,
setConfiguration(freemarker.template.Configuration)
getConfiguration
public freemarker.template.Configuration getConfiguration()
- Description copied from interface:
FreeMarkerConfig
- Return the FreeMarker Configuration object for the current
web application context.
A FreeMarker Configuration object may be used to set FreeMarker
properties and shared objects, and allows to retrieve templates.
- Specified by:
getConfiguration
in interface FreeMarkerConfig
- Returns:
- the FreeMarker Configuration
Copyright (C) 2003-2004 The Spring Framework Project.