struts2加载国际化资源文件方法

lihehua_1 10年前
    public void loadI18nCode() throws Exception{          HashMap<String, String> result = new HashMap<String, String>();          String[] aBundleNames = new String[]{              "i18n.root.error.haha",               "i18n.root.info.haha",               "i18n.root.ui.haha"          };          for (String aBundleName : aBundleNames) {              ResourceBundle rb = getTexts(aBundleName);              convert(result, rb);          }          returnJSON(result);      }        private void convert(HashMap<String, String> result, ResourceBundle rb) {          Enumeration<String> enumeration = rb.getKeys();          while (enumeration.hasMoreElements()) {              String keyName = enumeration.nextElement();              String keyValue = rb.getString(keyName);              result.put(keyName, keyValue);          }      }