Natlive's blog

A long way and dream.

 

自翻译·Freemarker 文档(一)

自己的英语水平只有一级半,为了努力学好英语,现在一天一个翻译,先从Freemarker文档开始,有不对的地方多谢指正抛砖。

Create a configuration instance
建立一个配置实例

First you have to create a freemarker.template.Configuration instance and adjust its settings. A Configuration instance is a central place to store the appliction level setting of FreeMarker. Also, it deals with the creation and caching of pre-parsed templates.
首先你必须建立一个freemarker.template.Configuration类的实例并调整它的设置. 一个Configuration类实例是保存Freemarker应用程序设置的中心首要. 同样, 它决定着预编译模版的建立和缓冲.

Probably you will do it only once at the beginning of the application(possibly servlet) life-cycle:
也许你只需要在程序开始时,仅仅只需调用一次下面的代码,并且在程序的整个生命周期都可用:

Configuration cfg = new Configuration();
// Specify the data source where the template files come from.
// 指定模板的数据源
// Here I set a file directory for it:
// 在这里我设置为一个目录
cfg.setDirectoryForTemplateLoading(new Fil("/where/you/store/templates"));
// Specify how templates will see the data model. This is an advanced topic
// 指定模板怎么读取数据模型(data model). 这是一个需要专门讨论的话题
// but just use this:
// 不过现在你可以这样做
cfg.setObjectWrapper(new DefaultObjectWrapper());  

From now you should use this single configuration instance. Note however that if a system has multiple independent components that use FreeMarker, then of course they will use their own private Configuration instance.
现在开始,你就可以使用这个Configuration实例了. 如果一个系统有多个模块使用Freemarker的话, 毫无意外的, 它们最后使用它们各自私有的Configuration实例.

posted on 2007-08-13 09:51 狂龙 阅读(979) 评论(1)  编辑  收藏 所属分类: Freemarker

评论

# re: 自翻译·Freemarker 文档(一) 2007-09-10 16:29 wojiushicai

好像少了点.....支持你楼主....加油..发更多的出来!!!  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿(2)

随笔分类

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜