【发布时间】:2011-03-27 12:11:25
【问题描述】:
出了点问题,非常令人沮丧。我在velocity的主页上读到,当我运行一个webapp时,应该设置一些属性。我已经做到了,但无论我做什么,我都会遇到同样的错误。
这是我设置道具并使用速度的地方
public class ConfirmationMailGenerator implements MailGenerator {
private BasicUser user;
private String htmlTemplate = "HTMLConfirmationMailTemplate.vsl";
private String plainTemplate = "PlainConfirmationMailTemplate.vsl";
public ConfirmationMailGenerator(BasicUser user) {
this.user = user;
}
public StringWriter generateHTML() throws Exception {
Properties props = new Properties();
props.setProperty("resource.loader", "wepapp");
props.setProperty("webapp.resource.loader.class", "org.apache.velocity.tools.view.WebappResourceLoader");
props.setProperty("webapp.resource.loader.path", "/WEB-INF/mailtemplates/");
VelocityEngine engine = new VelocityEngine(props);
VelocityContext context = new VelocityContext();
engine.init();
Map map = createDataModel();
context.put("user", map);
Template template = engine.getTemplate(htmlTemplate);
StringWriter writer = new StringWriter();
template.merge(context, writer);
return writer;
}
...
}
文件当然保存在 /WEB-INF/mailtemplates/ 中。
如果我使用它,我会收到此错误:
SEVERE: ResourceManager : unable to find resource 'HTMLConfirmationMailTemplate.vsl' in any resource loader.
SEVERE: The log message is null.
感谢您的宝贵时间:)
【问题讨论】:
标签: java web-applications velocity