解决ajax中文乱码

来源:互联网 发布:淘宝网站设计模板 编辑:程序博客网 时间:2024/05/16 11:43
function save(buttonObj){var jObj = $(buttonObj);title = jObj.attr("title");    address = jObj.attr("address");    var phoneNumber = jObj.attr("phone");    lon = jObj.attr("lon");    lat = jObj.attr("lat");$.ajax({   url:'../map-ajax/saveArrival.action?a='+Math.random(),     data : {  poiName:encodeURI(title),  poiAdd:encodeURI(address),   poiTel:phoneNumber,     poiLon:lon,   poiLat:lat,  poiType:"1"  },     type:'post',     dataType:'json',          success:function(data){         if(data.alertMessage != null && data.alertMessage != ""){         alert(data.alertMessage);         }else{         alert("保存失败,请重试再试!");                  }         }});}

后台解析

    String poiName = URLDecoder.decode(request.getParameter("poiName"),"utf-8");