繁体   English   中英

Apache velocity:org.apache.velocity.exception.ResourceNotFoundException

[英]Apache velocity: org.apache.velocity.exception.ResourceNotFoundException

我正在关注http://www.javaworld.com/article/2075966/core-java/start-up-the-velocity-template-engine.html教程。

我将我的vm文件保存在与我班级相同的文件夹中。 我收到以下异常:

Exception in thread "main" org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource

正如velocity文档所说,我需要JSP/servlet支持,而我现在还没有。

我哪里错了?

PS:我正在使用IntelliJ IDE

尝试在Velocity引擎中设置RuntimeConstants.RESOURCE_LOADERclasspath.resource.loader.class来查看源代码:

VelocityEngine engine = new VelocityEngine();
engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
engine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName())

//this is at src/main/java level, tested with Netbeans
Template yourTemplate = ve.getTemplate("yourTemplate.vm"); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM