Error: Required String parameter 'userName' is not present
分析:
参数不能传到后台,要么是前端参数传递的方式问题,要么是后台接受参数的问方式题
解决:
方式1:修改前端请求参数
修改wx.request()的请求头中的content-type:
wx.request({
url: url,
method: 'POST',
data:{你的数据},
header: {
'content-type': 'application/x-www-form-urlencoded',
},
success: (res) => {
console.log(res)
},
})
方式2:修改后端接受参数
@PostMapping("/getsessionId")
public Object getSessionId(@RequestBody Map<String,String> reqbody) {
String code = reqbody.get("code");
return ***;
}
(完)