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 狂龍 閱讀(1003) 評論(1)  編輯  收藏 所屬分類: Freemarker

          評論

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

          好像少了點.....支持你樓主....加油..發更多的出來!!!  回復  更多評論   


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          統計

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 新丰县| 红河县| 思南县| 太和县| 温宿县| 晋江市| 花莲市| 保定市| 广水市| 绥江县| 山阳县| 侯马市| 分宜县| 嘉兴市| 建宁县| 达拉特旗| 沂南县| 昌图县| 河津市| 即墨市| 罗源县| 承德县| 正宁县| 马关县| 南通市| 贵德县| 英德市| 板桥市| 龙岩市| 江都市| 县级市| 涿州市| 甘肃省| 永年县| 新邵县| 班戈县| 昭苏县| 云林县| 洱源县| 云龙县| 噶尔县|