版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_38361347/article/details/85260409
出现415错误的解决方法:
- 前端看ajax请求的contentType是否与后端一致
- 看发送的数据格式是否正确。
下面是后端所需数据为json格式,contentType为application/json的ajax请求。
$.ajax({
url:'/xxxxxx',
type:'POST',
contentType: 'application/json; charset=UTF-8',
dataType:'json',
data:JSON.stringify(data),
success: function (response) {
console.log(response);
}
});