[转载]NVelocity templates and absolute paths

[转载]NVelocity templates and absolute paths – George V. Reilly’s Technical Blog.

We’ve started using the NVelocity template formatting engine. We were absolutely stymied for an hour, trying to figure out how to get it working with an absolute path to the template file, instead of the relative path shown in the documentation.

The trick is to set file.resource.loader.path. Here’s how to load C:\foo\bar\somefile.vm:

 ExtendedProperties props = new ExtendedProperties();
 props.AddProperty("file.resource.loader.path", new ArrayList(new string[]{".", "C:\\"}));
 velocity.Init(props);

 template = velocity.GetTemplate("foo\\bar\\somefile.vm");
赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏