微信小程序向Java后端传递对象数据以及后端的接收(springboot)
话不多说,上代码
微信前端JS
data: {
loginForm: {
userId: '',
password: '',
}
},
wx.request({
url: 'http://localhost:9099/login',
method:'post',
data:that.data.loginForm,
header: { 'Content-Type': 'application/x-www-form-urlencoded' },
//注意这里使用的是请求头的请求类型是:application/x-www-form-urlencoded
Java后端接收
@RequestMapping("/login")
public CommonResponse<UserVo> login(UserVo userVo){
System.out.println(userVo.getUserId()+" ----"+userVo.getPassword());
return userService.login(userVo);
}