Class VelocityConfigurer
- java.lang.Object
- org.springframework.ui.velocity.VelocityEngineFactory
- org.springframework.web.servlet.view.velocity.VelocityConfigurer
- All Implemented Interfaces:
Aware
,InitializingBean
,ResourceLoaderAware
,ServletContextAware
,VelocityConfig
@Deprecated public class VelocityConfigurer extends VelocityEngineFactory implements VelocityConfig, InitializingBean, ResourceLoaderAware, ServletContextAware
Deprecated.as of Spring 4.3, in favor of FreeMarkerJavaBean to configure Velocity for web usage, via the "configLocation" and/or "velocityProperties" and/or "resourceLoaderPath" bean properties. The simplest way to use this class is to specify just a "resourceLoaderPath"; you do not need any further configuration then.<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <property name="resourceLoaderPath"><value>/WEB-INF/velocity/</value></property> </bean>
This bean must be included in the application context of any application using Spring'sVelocityView
for web MVC. It exists purely to configure Velocity; it is not meant to be referenced by application components (just internally by VelocityView). This class implementsVelocityConfig
in order to be found by VelocityView without depending on the bean name of this configurer. Each DispatcherServlet may define its own VelocityConfigurer if desired, potentially with different template loader paths.Note that you can also refer to a pre-configured VelocityEngine instance via the "velocityEngine" property, e.g. set up by
VelocityEngineFactoryBean
, This allows to share a VelocityEngine for web and email usage, for example.This configurer registers the "spring.vm" Velocimacro library for web views (contained in this package and thus in
spring.jar
), which makes all of Spring's default Velocity macros available to the views. This allows for using the Spring-provided macros such as follows:#springBind("person.age") age is ${status.value}
- Author:
- Rod Johnson, Juergen Hoeller, Darren Davison
- See Also:
VelocityEngineFactory.setConfigLocation(org.springframework.core.io.Resource)
,VelocityEngineFactory.setVelocityProperties(java.util.Properties)
,VelocityEngineFactory.setResourceLoaderPath(java.lang.String)
,setVelocityEngine(org.apache.velocity.app.VelocityEngine)
,VelocityView
Field Summary
Fields inherited from class org.springframework.ui.velocity.VelocityEngineFactory
logger
Constructor Summary
Constructors Constructor Description VelocityConfigurer()
Deprecated.
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
afterPropertiesSet()
Deprecated.Initialize VelocityEngineFactory's VelocityEngine if not overridden by a pre-configured VelocityEngine.org.apache.velocity.app.VelocityEngine
getVelocityEngine()
Deprecated.Return the VelocityEngine for the current web application context.protected void
postProcessVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine)
Deprecated.Provides a ClasspathResourceLoader in addition to any default or user-defined loader in order to load the spring Velocity macros from the class path.void
setServletContext(ServletContext servletContext)
Deprecated.Set theServletContext
that this object runs in.void
setVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine)
Deprecated.Set a pre-configured VelocityEngine to use for the Velocity web configuration: e.g.Methods inherited from class org.springframework.ui.velocity.VelocityEngineFactory
createVelocityEngine, getResourceLoader, initSpringResourceLoader, initVelocityResourceLoader, isPreferFileSystemAccess, newVelocityEngine, setConfigLocation, setOverrideLogging, setPreferFileSystemAccess, setResourceLoader, setResourceLoaderPath, setVelocityProperties, setVelocityPropertiesMap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ResourceLoaderAware
setResourceLoader
Constructor Detail
VelocityConfigurer
public VelocityConfigurer()
Deprecated.
Method Detail
setVelocityEngine
public void setVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine)
Deprecated.Set a pre-configured VelocityEngine to use for the Velocity web configuration: e.g. a shared one for web and email usage, set up viaVelocityEngineFactoryBean
.Note that the Spring macros will not be enabled automatically in case of an external VelocityEngine passed in here. Make sure to include
spring.vm
in your template loader path in such a scenario (if there is an actual need to use those macros).If this is not set, VelocityEngineFactory's properties (inherited by this class) have to be specified.
setServletContext
public void setServletContext(ServletContext servletContext)
Deprecated.Description copied from interface:ServletContextAware
Set theServletContext
that this object runs in.Invoked after population of normal bean properties but before an init callback like InitializingBean's
afterPropertiesSet
or a custom init-method. Invoked after ApplicationContextAware'ssetApplicationContext
.- Specified by:
setServletContext
in interfaceServletContextAware
- Parameters:
servletContext
- ServletContext object to be used by this object- See Also:
InitializingBean.afterPropertiesSet()
,ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
afterPropertiesSet
public void afterPropertiesSet() throws IOException, org.apache.velocity.exception.VelocityException
Deprecated.Initialize VelocityEngineFactory's VelocityEngine if not overridden by a pre-configured VelocityEngine.- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
IOException
org.apache.velocity.exception.VelocityException
- See Also:
VelocityEngineFactory.createVelocityEngine()
,setVelocityEngine(org.apache.velocity.app.VelocityEngine)
postProcessVelocityEngine
protected void postProcessVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine)
Deprecated.Provides a ClasspathResourceLoader in addition to any default or user-defined loader in order to load the spring Velocity macros from the class path.- Overrides:
postProcessVelocityEngine
in classVelocityEngineFactory
- Parameters:
velocityEngine
- the current VelocityEngine- See Also:
ClasspathResourceLoader
getVelocityEngine
public org.apache.velocity.app.VelocityEngine getVelocityEngine()
Deprecated.Description copied from interface:VelocityConfig
Return the VelocityEngine for the current web application context. May be unique to one servlet, or shared in the root context.- Specified by:
getVelocityEngine
in interfaceVelocityConfig
- Returns:
- the VelocityEngine