问题:原请求后台获取数据为null
修改后:
后台控制器controller
@PostMapping("test")
@ResponseBody
public Object test(@RequestParam Map<String, String> map){
Sysout.out.println("post");
return materialService.selectById(map.get("id"));
}
微信小程序请求代码js
wx.request({
url: 'http://127.0.0.1:8080/test',
method: "POST",//指定请求方式,默认get
data: { id: 2010140},
header: {
//默认值'Content-Type': 'application/json'
'content-type': 'application/x-www-form-urlencoded' //post
},
success: function (res) {
console.log(res.data)
}
});