标签:class load div mave 项目 index time property 路径
加载classpath目录下的vm文件,或者maven项目的resources路径下
Properties p = new Properties();
p.put("file.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
Velocity.init(p);
...
Velocity.getTemplate(templateFile);
通过绝对路径来加载,模版文件位于磁盘中,如:D:\\template\\index.vm
Properties p = new Properties();
p.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, "D:\\template");
Velocity.init(p);
...
Velocity.getTemplate("index.vm");
通过加载properties文件中的配置,加载类路径下的模版文件
Properties p = new Properties();
p.load(this.getClass().getResourceAsStream("/velocity.properties"));
Velocity.init(p);
...
Velocity.getTemplate(templateFile);
标签:class load div mave 项目 index time property 路径
原文地址:https://www.cnblogs.com/geekdc/p/8970570.html