【发布时间】:2011-04-26 08:41:52
【问题描述】:
我正在为我的 Web 应用程序使用 Spring MVC,并且我正在集成 Velocity 来模板化我的电子邮件。
当它尝试发送我的电子邮件时,我收到以下 500 错误。
org.apache.velocity.exception.ResourceNotFoundException:
Unable to find resource '/WEB-INF/velocity/registrationEmail.vm'
我知道这意味着什么以及我需要做什么,但我知道我一定做错了什么,我无法弄清楚为什么它找不到我的 .vm 文件。 p>
我在 applicationContext.xml 文件中配置了速度,如下所示,但我相信我可能会遗漏 Velocity 需要查找文件的必要属性。
<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
</value>
</property>
</bean>
<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath" value="/WEB-INF/velocity/"/>
</bean>
我相信这可能是我需要进行一些更改/添加的地方,但我不确定。
我的模板文件的路径是WEB-INF/velocity/templateName.vm
我在控制器中使用velocityEngine bean时也指定了这一点,如下所示
字符串文本 = VelocityEngineUtils.mergeTemplateIntoString(
velocityEngine, "/WEB-INF/velocity/registrationEmail.vm", test);
我需要在 build.xml 文件中做些什么来确保它能够找到我的模板文件吗?
【问题讨论】: