700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > java http 415错误_SpringMVC ajax提交json报415错误

java http 415错误_SpringMVC ajax提交json报415错误

时间:2022-12-29 05:08:34

相关推荐

java http 415错误_SpringMVC ajax提交json报415错误

具体报错信息如下HTTP Status 415 -

type Status report

message

description The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.

我提交的表单内容转成了json,因为不想再做数据转换的代码,我用的是easyui。把更新过的列都读取出来,代码如下所示varrows=$('#dg').datagrid('getChanges',2);

ajax提交的代码如下所示$.ajax({

type:"post",

url:'',

data:$.toJSON(rows),

dataType:"json",

async:false,

success:function(data,status){

}

},2);

提交ajax就报HTTP Status 415错误了。解决该问题的方法很简单,就是加上代码:contentType: "application/json",具体代码如下$.ajax({

type:"post",

url:'',

data:$.toJSON(rows),

dataType:"json",

contentType:"application/json",

async:false,

success:function(data,status){

}

},2);

这样就解决415错误提示了。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。