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)

          隨筆分類

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 泰州市| 佛山市| 双牌县| 永登县| 秦皇岛市| 田东县| 刚察县| 密山市| 浑源县| 娱乐| 香港 | 奉化市| 余姚市| 屯昌县| 宝鸡市| 泗水县| 红河县| 张家港市| 浦县| 田阳县| 山东| 清新县| 甘谷县| 醴陵市| 阳东县| 孟州市| 从化市| 宁明县| 微山县| 牙克石市| 张家口市| 巩留县| 青铜峡市| 绵竹市| 罗甸县| 青浦区| 府谷县| 繁昌县| 长武县| 莱芜市| 旺苍县|