spring中做成bean,可以使用property"resourceLoaderPath"指定工程中的路径

<bean >
<property name="resourceLoaderPath" value="/WEB-INF/classes/templet" />
<property name="velocityProperties">
<props>
<prop key="velocimacro.library">*.vm</prop>
<prop key="default.contentType">text/html; charset=utf-8</prop>
<prop key="output.encoding">utf-8</prop>
<prop key="input.encoding">utf-8</prop>
</props>
</property>
</bean>

 

如果是new velocityEngine的实例,例如用在test中
可以这样指定路径
VelocityEngine velocityEngine = new VelocityEngine();
Properties p = new Properties();
p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, "E:/reyo/project/WEB-INF/classes/templet");
velocityEngine.init(p);

 

相关文章:

  • 2021-06-05
  • 2021-07-10
  • 2021-05-25
  • 2021-11-08
  • 2021-10-01
  • 2021-12-07
  • 2021-09-23
猜你喜欢
  • 2022-01-04
  • 2021-09-29
  • 2021-09-17
  • 2022-01-03
  • 2022-12-23
  • 2021-11-09
相关资源
相似解决方案