类 VelocityConfigurer
- 所有已实现的接口:
VelocityConfig,org.springframework.beans.factory.Aware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ResourceLoaderAware,org.springframework.web.context.ServletContextAware
<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's
VelocityView 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 implements VelocityConfig
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}- 作者:
- Rod Johnson, Juergen Hoeller, Darren Davison
- 另请参阅:
-
字段概要
从类继承的字段 cn.aradin.spring.velocity.ui.VelocityEngineFactory
logger -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidInitialize VelocityEngineFactory's VelocityEngine if not overridden by a pre-configured VelocityEngine.org.apache.velocity.app.VelocityEngineReturn the VelocityEngine for the current web application context.protected voidpostProcessVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine) Provides a ClasspathResourceLoader in addition to any default or user-defined loader in order to load the spring Velocity macros from the class path.voidsetServletContext(jakarta.servlet.ServletContext servletContext) voidsetVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine) 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.从类继承的方法 cn.aradin.spring.velocity.ui.VelocityEngineFactory
createVelocityEngine, getResourceLoader, initSpringResourceLoader, initVelocityResourceLoader, isPreferFileSystemAccess, newVelocityEngine, setConfigLocation, setPreferFileSystemAccess, setResourceLoader, setResourceLoaderPath, setVelocityProperties, setVelocityPropertiesMap从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 org.springframework.context.ResourceLoaderAware
setResourceLoader
-
构造器详细资料
-
VelocityConfigurer
public VelocityConfigurer()
-
-
方法详细资料
-
setVelocityEngine
public void setVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine) 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.vmin 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.
- 参数:
velocityEngine- velocityEngine
-
setServletContext
public void setServletContext(jakarta.servlet.ServletContext servletContext) - 指定者:
setServletContext在接口中org.springframework.web.context.ServletContextAware
-
afterPropertiesSet
public void afterPropertiesSet() throws IOException, org.apache.velocity.exception.VelocityExceptionInitialize VelocityEngineFactory's VelocityEngine if not overridden by a pre-configured VelocityEngine.- 指定者:
afterPropertiesSet在接口中org.springframework.beans.factory.InitializingBean- 抛出:
IOExceptionorg.apache.velocity.exception.VelocityException- 另请参阅:
-
postProcessVelocityEngine
protected void postProcessVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine) Provides a ClasspathResourceLoader in addition to any default or user-defined loader in order to load the spring Velocity macros from the class path.- 覆盖:
postProcessVelocityEngine在类中VelocityEngineFactory- 参数:
velocityEngine- the current VelocityEngine- 另请参阅:
-
ClasspathResourceLoader
-
getVelocityEngine
public org.apache.velocity.app.VelocityEngine getVelocityEngine()从接口复制的说明:VelocityConfigReturn the VelocityEngine for the current web application context. May be unique to one servlet, or shared in the root context.- 指定者:
getVelocityEngine在接口中VelocityConfig- 返回:
- the VelocityEngine
-