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


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

    参数有问题,不能解析成json对象

    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); } });

    注意:

    后端如果用springMVC的@RequestBody注解的话,则只能Json对象的字符串,不能接收Json对象,用 JSON.stringify(data)的方式将对象变成字符串,同时ajax请求也要指定dataType: "json",contentType:"application/json" ,这样就能用@RequestBody注解绑定对象或者List集合.

  • 相关阅读:
    &&和||解析
    SQL-union union all
    sql杂记
    JAVA杂记
    sql之left join、right join、inner join的区别
    蓝鲸邮箱配置
    快速部署社区版(详解)
    蓝鲸平台安装环境准备
    蓝鲸脚本集合
    zabbix3.4 install
  • 原文地址:https://www.cnblogs.com/skyessay/p/6544738.html
Copyright © 2020-2023  润新知