简体   繁体   English

速度。 无法加载我的资源

[英]Velocity. Can't load my resources

structure of my project: 我的项目结构:

-src
--main
---java
----makers
-----SomeClass
---resources
----htmlPattern.vm

How tell to SomeClass about htmlPattern. 如何告诉SomeClass有关htmlPattern的信息。 I try something like this: 我尝试这样的事情:

    VelocityEngine ve = new VelocityEngine();
    Properties properties = new Properties();
    properties.setProperty("resource.loader", "file");
    properties.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
    properties.setProperty("file.resource.loader.path", "resources");
    properties.setProperty("file.resource.loader.cache", "true");
    properties.setProperty("file.resource.loader.modificationCheckInterval", "2");
    ve.init(properties);

    Template t = ve.getTemplate("htmlPattern.vm", "utf-8");

What's wrong? 怎么了? The IDE says: IDE说:

org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'htmlPattern.vm'

I solved my problem. 我解决了我的问题。

    VelocityEngine ve = new VelocityEngine();
    Properties properties = new Properties();
    properties.setProperty("resource.loader", "file");
    properties.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
    ve.init(properties);

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

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