错误:“Content type ‘applicationx-www-form-urlencoded;charset=UTF-8‘ not supported

tech2023-10-11  102

controller:

@RequestMapping(value = "/updateToDispatch", method = RequestMethod.POST, produces = "application/json; charset=utf-8")

JS:

$.ajax({ cache : true, type : "POST", contentType: "application/json", url :'http://localhost:5061/yunwei/order/updateToCancel', data : JSON.stringify({ "workNo":workNo, "empNo": empNo, "empName": empName, "cancelReason": cancelReason }),

解决方案:

添加:

contentType: "application/json" data : JSON.stringify()

 

 JSON.stringify()   ==>        方法用于将 JavaScript 值转换为 JSON 字符串


最新回复(0)