VelocityEngine ve = new VelocityEngine();
Properties p = new Properties();
p.put(Velocity.FILE_RESOURCE_LOADER_PATH, Activator.getDefault().getBundle().getLocation().replaceAll("reference:file:/", "") + "template");
ve.init(p);
Template template = ve.getTemplate(templateFilePath, inEncode);
上面的代码,在开发环境下是可以获取vm模板的,但是项目打成jar包后,放到eclipse的plugins目录下后,就找不到vm文件了。(vm文件已经打到jar包了)
其实就是想问p.put()的第二个参数,应该填啥。求指导,谢谢了。
高洛峰2017-04-21 10:58:54
rootPath = event.getServletContext().getRealPath("/");// Get the absolute path. By design, the caller implements its own path to pass in