请教一个问题,为什么在action中jsonobject对象存储中文信息,用jquery ajax获取返回信息为空?使用的是net.sf.json.JSONObject,用gson也不可以,一样的结果。action代码
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray(); jsonObject.accumulate("orderno", hipPolicyDetails
.getOrdernumber());
for (HipCustomer bhCustomer : hipCustomers) {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.accumulate("bname", bhCustomer.getName());
jsonObject1.accumulate("bidtype", bhCustomer.getIdType());
jsonObject1.accumulate("bidno", bhCustomer.getIdNo());
jsonObject1.accumulate("bbirth", CommonDao.converToString(
bhCustomer.getBirth(), "yyyy-MM-dd"));
jsonObject1.accumulate("btel", bhCustomer.getTel());
jsonArray.add(jsonObject1);
}
jsonObject.accumulate("hipCustomers", jsonArray);
response.getWriter().write(jsonObject.toString());
js代码 $.ajax({
async:false,
type:'post',
dataType:'json',
url:'',
data:d,
error:function(msg){
},success:function(msg)
{
var dlist=msg.hipCustomers;
}
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray(); jsonObject.accumulate("orderno", hipPolicyDetails
.getOrdernumber());
for (HipCustomer bhCustomer : hipCustomers) {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.accumulate("bname", bhCustomer.getName());
jsonObject1.accumulate("bidtype", bhCustomer.getIdType());
jsonObject1.accumulate("bidno", bhCustomer.getIdNo());
jsonObject1.accumulate("bbirth", CommonDao.converToString(
bhCustomer.getBirth(), "yyyy-MM-dd"));
jsonObject1.accumulate("btel", bhCustomer.getTel());
jsonArray.add(jsonObject1);
}
jsonObject.accumulate("hipCustomers", jsonArray);
response.getWriter().write(jsonObject.toString());
js代码 $.ajax({
async:false,
type:'post',
dataType:'json',
url:'',
data:d,
error:function(msg){
},success:function(msg)
{
var dlist=msg.hipCustomers;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货