SpringMVC Ajax接口: Content type ‘application/x-www-form-urlencoded;charset=UTF-8’ not supported

造成这个错误的原因是AJAX没有正确设置 Content-type

手工指定Content-type后,问题解决

 

$.ajax({
type: "POST",
url: "/interface/json2book",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({id:1,name:"aaa"}),
dataType: "json",
success: function (message) {
alert(message);
},
error: function (message) {
alert(message);
}
});