【发布时间】:2021-04-22 20:08:12
【问题描述】:
我目前正在使用 Spark,并尝试通过 Velocity 使用基于 documentation 的模板。
但是我遇到了一些错误,谁能提供有关如何成功加载模板的指导?
Aug 22, 2017 2:26:43 PM org.apache.velocity.runtime.log.JdkLogChute log
SEVERE: ResourceManager : unable to find resource 'www/templates/template.html' in any resource loader.
[qtp1951434327-14] ERROR spark.http.matching.GeneralError -
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'www/templates/template.html'
public class Minimal {
public static void main(String[] args) {
get("test", (req, res) -> {
Map<String, Object> model = new HashMap<>();
return render(model, "www/templates/template.html");
});
}
public static String render(Map<String, Object> model, String path) {
return new VelocityTemplateEngine().render(new ModelAndView(model, path));
}
}
我已经阅读并尝试了许多 Stack Overflow 问题的解决方案,但它们似乎都对我的情况没有帮助。
一些解决方案包括设置属性,或具有特定的项目结构等。虽然看起来这些都没有解决问题,并导致同样的异常。
【问题讨论】:
标签: java velocity spark-java apache-velocity