参考自:http://blog.csdn.net/a61595579/article/details/53404451
content-type设置为application/x-www-form-urlencoded的情况:
sendRequest: function (e) { console.log('执行方法...'); wx.request({ url: 'http://iscream.ngrok.cc/qpi/rest/crmServiceInfo/deleteRecord', data:{fileId:'123'}, method:'POST', header: { 'content-type': 'application/x-www-form-urlencoded' }, success:function(res){ console.log('data:' + res.data); console.log('header:' + res.header); console.log('statusCode:' + res.statusCode); } }) },
这是调试中的数据:
这样的数据后台可以获取:
@POST @Path("deleteRecord") @Produces(MediaType.APPLICATION_JSON) public String deleteRecord(@FormParam("fileId")String fileId){ System.out.println("fileId:" + fileId); return "test"; }
如果是不填写header,则默认content-type为application/json,这样的话调试中的数据为:
后台就获取不到了,res.data就可以获取到"test"返回数据了
wx.request中的data参数传递
最新推荐文章于 2024-05-28 11:04:58 发布