kino
kino
  • 发布:2016-10-24 16:37
  • 更新:2016-10-24 16:57
  • 阅读:2758

mui.ajax post请求 java服务端拿不到参数

分类:MUI

前端代码:
mui.ajax(submitUrl,{
data:param,
dataType:'json',//服务器返回json格式数据
type:'post',//HTTP请求类型
timeout:10000,//超时时间设置为10秒;
headers:{'Content-Type':'application/json'},
success:function(data){
if(data.rt == 0){
alert('操作成功!');
window.location.reload(true);
return;
}else if(data.rt == 20004 || data.rt == 20001){
alert('该玩家不存在!');
return;
}else{
alert('操作异常!');
return;
}
},
error:function(xhr,type,errorThrown){
console.log("xhr请求失败:" + errorThrown);
console.log("xhr请求失败:" + type);
console.log("xhr请求失败:" + xhr.status);
}
});

服务端代码
String strPlayerName = req.getParameter(CommandDefine.param_string);
String strResVal = req.getParameter(CommandDefine.param_string2);
String strJsonp = req.getParameter(CommandDefine.param_string3);

拿不到参数

2016-10-24 16:37 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com

var submitUrl= ’你对应的接口地址’;
你少了请求的地址吧

  • kino (作者)

    这个是变量 有值的 请求到服务端了 但是参数都是null

    2016-10-24 16:50

1***@qq.com

1***@qq.com

contenttype 换成application/x-www-form-urlencoded 试试

  • 1***@qq.com

    headers:{'Content-Type':'application/json'}, 改成 "contentType": "application/x-www-form-urlencoded; charset=utf-8",

    2016-10-24 17:01

  • kino (作者)

    没用 早试过了

    2016-10-24 17:05

  • 1***@qq.com

    那就是你的param 里的参数值有问题了 不行的就等别人帮你了兄弟

    2016-10-24 17:10

该问题目前已经被锁定, 无法添加新回复