带 Spark 的速度模板引擎
Velocity Template Engine with Spark
我目前正在使用 spark-java 动态生成网站。
我的文件夹结构如下:
FATAL: ResourceManager : unable to find resource 'test.vm' in any resource loader.
然而,当我尝试加载页面时,出现了这个错误。我的代码如下所示:
get("/helloworld", (req, res) -> {
Map<String, Object> model = new HashMap<String, Object>();
model.put("test", "Hey there :)");
return new ModelAndView(model, "test.vm");
}, new VelocityTemplateEngine());
没有 Velocity 的页面加载没有问题。谁能帮我正确设置?
您的速度模板文件 (test.vm
) 应该在目录 src/main/resources
.
中
您的资源文件夹目前不在 classpath
上,因此找不到文件。
我目前正在使用 spark-java 动态生成网站。
我的文件夹结构如下:
FATAL: ResourceManager : unable to find resource 'test.vm' in any resource loader.
然而,当我尝试加载页面时,出现了这个错误。我的代码如下所示:
get("/helloworld", (req, res) -> {
Map<String, Object> model = new HashMap<String, Object>();
model.put("test", "Hey there :)");
return new ModelAndView(model, "test.vm");
}, new VelocityTemplateEngine());
没有 Velocity 的页面加载没有问题。谁能帮我正确设置?
您的速度模板文件 (test.vm
) 应该在目录 src/main/resources
.
您的资源文件夹目前不在 classpath
上,因此找不到文件。