如何正确设定装载机的速度路径 [英] How to set properly the loader path of velocity
本文介绍了如何正确设定装载机的速度路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望我的Velocityengine从设计的路径中查找模板. 我是这样做的:
i would like that my velocityengine look for templates from a designed path. i did this :
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="velocityProperties">
<value>
resource.loader=class
class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
class.resource.loader.resourceLoaderPath=/mytemplates
</value>
</property>
,但仍在classes文件夹中寻找模板. 有什么主意吗?
but is still looking for templates in the classes folder. any idea?
推荐答案
As illustrated in the spring documentation, you could try the following:
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="velocityProperties">
<props>
<prop key="resource.loader">file</prop>
<prop key="file.resource.loader.class">
org.apache.velocity.runtime.resource.loader.FileResourceLoader
</prop>
<prop key="file.resource.loader.path">${webapp.root}/WEB-INF/velocity</prop>
<prop key="file.resource.loader.cache">false</prop>
</props>
</property>
</bean>
或者,您可以在velocity.properties
中声明这些属性并指定
Alternately, you could declare these properties in a velocity.properties
and specify that
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="configLocation" value="/WEB-INF/velocity.properties"/>
</bean>
这篇关于如何正确设定装载机的速度路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文