- hello=englishww
- name=english zk
- emailEmpty=Field cannot be empty!
- emailInvalid=Invalid email address!
- $.ajax({
- type:'POST',
- dataType:'json',
- url:'/jeecms/jeecms/ajax/cms/getResourceBundle.do',
- async:false,
- success:function(data){
- jsonData=data.jsI18n;//jsI18n是java返回时赋予的名称
- jsi18n=eval_r('('+jsonData+')');//转化为json对象
- alert("property is "+jsi18n.hello);
- },
- error:function(data){
- alert("error");
- }
- });
- publicString getResourceBundle(){
- ResourceBundle RESOURCE_BUNDLE;
- if(contextPvd.getSessionAttr("gLanguage")!=null&&contextPvd.getSessionAttr("gLanguage").equals("1")){
- RESOURCE_BUNDLE=ResourceBundle.getBundle("jsI18n",Locale.ENGLISH);
- }else{
- RESOURCE_BUNDLE =ResourceBundle.getBundle("jsI18n",Locale.CHINA);
- }//判断语言类别的,忽视
- Set keySet=RESOURCE_BUNDLE.keySet();
- //读取资源文件数据拼接成json格式字符串返回
- String jsonString = newString();
- jsonString+="{";
- for(String key:keySet){
- jsonString+='"'+key+'"'+":"+'"'+RESOURCE_BUNDLE.getString(key)+'"'+",";
- }
- jsonRoot.put("jsI18n",jsonString.substring(0,jsonString.length()-1)+"}");
- return SUCCESS;
- }