转载: https://blog.csdn.net/qq_37164847/article/details/88885917
后台接收参数:
// 删除用户
@PostMapping("/del")
public AppResult<String> del(@Param("userId")long userId){
log.info("删除用户");
log.info("删除用户userId:"+userId);
return AppResultBuilder.success("删除成功", ResultCode.SUCCESS);
}
原始前端传递参数:
$.ajax({
headers: {
"Authorization":token//此处放置请求到的用户token
},
url:posturl,
type: "post",
data:{"userId":22},
contentType: "application/json",
dataType: 'json',
async: true,
success: function(res) {
console.log("提交结果=="+JSON.stringify(res));
},
error:function() {
console.log("提交失败");
}
});
后端接收显示是null,解决:
把 contentType: "application/json",
dataType: 'json',
去掉