加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ajax进行post请求,后台@RequestBody绑定实体类报错的问题

发布时间:2020-12-16 03:01:49 所属栏目:百科 来源:网络整理
导读:Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token ‘name‘: was expecting (‘true‘,‘false‘ or ‘null‘) 报错原因:发送的 json object 不符合 json 规范,后台无法解析。(Ajax跨域问题?) 解决方法: ajax提交添加下面两

Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token ‘name‘: was expecting (‘true‘,‘false‘ or ‘null‘)

报错原因:发送的 json object 不符合 json 规范,后台无法解析。(Ajax跨域问题?)

解决方法:

ajax提交添加下面两行代码

contentType:‘application/json;charset=utf-8‘
data:JSON.stringify(数据)

var allData = {          name:"张三",          age:20         };$.ajax({
            type: "POST",url: "xxxx",contentType:‘application/json;charset=utf-8‘,data:JSON.stringify(allData),success: function (data) {
                alert(data);
            }
        });http://www.mamicode.com/info-detail-1721637.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读