隨筆 - 119  文章 - 3173  trackbacks - 0
          <2007年5月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          交友莫獨酒,茅臺西鳳游。
          口干古井貢,心徜洋河流。
          稱多情杜康,趟無量雙溝。
          贊中華巍巍,無此不銷愁。

          常用鏈接

          留言簿(68)

          隨筆分類(136)

          隨筆檔案(122)

          最新隨筆

          搜索

          •  

          積分與排名

          • 積分 - 526734
          • 排名 - 92

          最新評論

          看了2天freemarker的源碼,終于有了收獲,通過ResourceBundleModel這個對象就能在freemarker中使用資源文件了。。。。。。。。。。。。

          程序中這樣寫:
          ResourceBundle?RESOURCE_BUNDLE?=?ResourceBundle.getBundle("ApplicationResources");
          ???ResourceBundleModel?rsbm?
          =?new?ResourceBundleModel(RESOURCE_BUNDLE,new?BeansWrapper());
          ???root.put(
          "bundle",?rsbm);



          模板中這樣寫
          <html>
          <head>
          ??
          <title>歡迎!</title>
          ??
          <META?HTTP-EQUIV="Content-Type"?CONTENT="text/html;?charset=utf-8">
          </head>
          <body>
          ??
          <h1>你好?${user}!</h1>
          ??
          <h1>Welcome?${bundle("name")}</h1>
          ??
          <h1>${bundle("hello","hermit")}</h1>
          </body>
          </html>


          中文結果
          <html>
          <head>
          ??
          <title>歡迎!</title>
          ??
          <META?HTTP-EQUIV="Content-Type"?CONTENT="text/html;?charset=utf-8">
          </head>
          <body>
          ??
          <h1>你好?hermit!</h1>
          ??
          <h1>Welcome?交口稱贊</h1>
          ??
          <h1>你好?hermit!</h1>
          </body>
          </html>

          英文
          <html>
          <head>
          ??
          <title>歡迎!</title>
          ??
          <META?HTTP-EQUIV="Content-Type"?CONTENT="text/html;?charset=utf-8">
          </head>
          <body>
          ??
          <h1>你好?hermit!</h1>
          ??
          <h1>Welcome?hermit</h1>
          ??
          <h1>hello?hermit!</h1>
          </body>
          </html>
          posted on 2007-05-11 10:27 交口稱贊 閱讀(3510) 評論(8)  編輯  收藏 所屬分類: freemarker

          FeedBack:
          # re: 在freemarker中直接使用資源文件做多語言國際化 2007-05-11 23:45 kkkk
          3X  回復  更多評論
            
          # re: 在freemarker中直接使用資源文件做多語言國際化 2007-05-15 13:59 lxy
          能否具體些 指點迷津不勝感激!  回復  更多評論
            
          # re: 在freemarker中直接使用資源文件做多語言國際化 2007-05-15 14:01 lxy
          神了  回復  更多評論
            
          # re: 在freemarker中直接使用資源文件做多語言國際化 2007-05-15 14:42 交口稱贊
          版主看不上
          俺這文章沒技術含量,不給發到首頁。
          沒意思,不寫freemarker的文章了  回復  更多評論
            
          # re: 在freemarker中直接使用資源文件做多語言國際化 2007-08-19 16:28 Hmilyld
          org.apache.jasper.JasperException: Can't find bundle for base name ApplicationResources, locale zh_CN

          納悶了,我老是報這個錯.
          Struts+FreeMarker.
          郁悶.  回復  更多評論
            
          # re: 在freemarker中直接使用資源文件做多語言國際化 2007-08-19 19:28 Hmilyld
          搞定了.呵呵.:)
          資源文件只寫了個名稱,像你上面那樣,
          原來要寫全的,加上包名就OK勒。  回復  更多評論
            
          # re: 在freemarker中直接使用資源文件做多語言國際化[未登錄] 2008-07-18 15:55 mike
          好人啊!真的是把包名寫全就可以了!  回復  更多評論
            
          # re: 在freemarker中直接使用資源文件做多語言國際化 2012-05-21 11:32 深度
          @Hmilyld
          你那是取得中文,亂碼了  回復  更多評論
            
          主站蜘蛛池模板: 河曲县| 名山县| 伊宁县| 富源县| 新津县| 绥化市| 华宁县| 苗栗市| 高唐县| 潜江市| 夏邑县| 全南县| 衡阳市| 石棉县| 正阳县| 长垣县| 全椒县| 台州市| 彭泽县| 休宁县| 洪洞县| 县级市| 德阳市| 三台县| 陆川县| 濉溪县| 林芝县| 济南市| 竹北市| 砀山县| 米泉市| 长兴县| 海林市| 江永县| 枣强县| 衡阳县| 博客| 环江| 根河市| 嘉善县| 淮安市|