How to set properly the loader path of velocity

▼魔方 西西 提交于 2019-11-30 06:48:54

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>

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>
Subhrajyoti Majumder

Try this:

<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
    <property name="resourceLoaderPath" value="/email_templates/"/>
</bean>

<bean name="mailTest" class="com.crisil.web.MailTestController">
    <property name="velocityEngine" ref="velocityEngine"/>
</bean>

Try with Resource Loader as

org.apache.velocity.runtime.resource.loader.FileResourceLoader

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!