1. "Content-Type":"application/json"
header: {
"Content-Type":"Content-Type":"application/json"
},
data() {
return {
Custom: {
userId: null,
....
}
}
}
前端请求直接传Custom对象
后端接收的时候,自己封装一个复合类
public class Custom extends WorkPwk {
private String userId;
}
@ResponseBody
public CommonResult list(@RequestBody Custom custom) {
....
}
2. "Content-Type":"application/x-www-form-urlencoded"
header: {
"Content-Type":"application/x-www-form-urlencoded"
},
前端请求求
let data = this.workPwk
data.userId = this.userId
uniAjax(
'/user/list',
data,
'POST',
success => {},
error => {},
complete => {}
);
后端接收的时候
@ResponseBody
public CommonResult list(String userId,WorkPwk workPwk) {
....
}
ps: 第二种是在小程序中使用的,未在其他测试