您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

ajax读取properties步骤详解

2024/5/5 15:14:54发布22次查看
这次给大家带来ajax读取properties步骤详解,ajax读取properties的注意事项有哪些,下面就是实战案例,一起来看一下。
properties资源文件的内容如下:
hello=englishww name=english zk emailempty=field cannot be empty! emailinvalid=invalid email address!
js调用ajax处理代码:
$.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);  } });
java处理文件getresourcebundle.do代码:
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)+''+,; } //把字符串赋给返回对象的jsi18n(这里随意) jsonroot.put(jsi18n,jsonstring.substring(0,jsonstring.length()-1)+}); return success; }
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
jquery+与ajax怎么实现局部刷新功能
怎么使用ajax实现循环
以上就是ajax读取properties步骤详解的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product