解决org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource


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

<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<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);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM