eclipse插件开发中,无法获取velocity模板

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()的第二个参数,应该填啥。求指导,谢谢了。

阅读 4.7k
1 个回答

rootPath = event.getServletContext().getRealPath("/");// 获得绝对路径。通过设计,调用方实现自己的路径传入

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进