Java控制台接收前端数据出现这个错误:
1.前端发送ajax请求的时候,需要指定contentType为application/json;charset=UTF-8
2.前端ajax的data发送的数据格式是JSON对象转字符串,利用JSON.stringify()
3.Controller中接口的接收参数之前要加上@RequestBoby,方法上贴上@ResponseBody注解
@RequestMapping("/add")
@ResponseBody
public AjaxResult addSave2(@RequestBody Appointment appointment){
appointmentService.save(appointment);
return AjaxResult.success();
}