質問

structure of my project:

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

How tell to SomeClass about 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:

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帰属
所属していません StackOverflow
scroll top