zoukankan      html  css  js  c++  java
  • Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'XXXX': was expecting ('true', 'false' or 'null')

    这个问题是因为前端传值有问题

    jquery ajax代码 

    $.ajax({
    type:"post",
    url:"/webswmm/runModel",
    dataType:'json',
    contentType:"application/json;charset=UTF-8",
    data:{name:'goatling'},
    async:true,
    success:function (data) {
    removeLoading('test');
    showAlertDiologue("success","run");
    resultUrl=data;
    },
    error:function () {
    removeLoading('test');
    showAlertDiologue("fail","run");
    }
    });
    @RequestMapping("/webswmm/runModel")
    @ResponseBody
    public JSONArray runModel(@RequestBody JSONObject jsonObject)
    {

    return dataService.runModel(jsonObject);
    }
    报错:

    JSON parse error: Unrecognized token 'name': was expecting 'null', 'true', 'false' or NaN; nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'name': was expecting 'null', 'true', 'false' or NaN
    at [Source: (PushbackInputStream); line: 1, column: 6]
    原因:

    {name:'goatling'} 这种形式根本不是标准JSON字符串

      '{"name":"goatling"}'  这个才是标准JSON字符串

    改正后:

    $.ajax({
    type:"post",
    url:"/webswmm/runModel",
    dataType:'json',
    contentType:"application/json;charset=UTF-8",
    data:'{"name":"goatling"}',
    async:true,
    success:function (data) {
    removeLoading('test');
    showAlertDiologue("success","run");
    resultUrl=data;
    },
    error:function () {
    removeLoading('test');
    showAlertDiologue("fail","run");
    }
    });
    这样才能成功在后台接收到。

  • 相关阅读:
    Java 泛型 泛型的约束与局限性
    Java 泛型 泛型方法
    Java 泛型 泛型数组
    Java 泛型 协变性、逆变性
    Java 泛型 协变式覆盖和泛型重载
    Java 泛型 泛型代码和虚拟机
    Insertion Sort List
    Remove Duplicates from Sorted List II
    String to Integer (atoi)
    SpringMvc源码入门
  • 原文地址:https://www.cnblogs.com/dqiii/p/13159460.html
Copyright © 2011-2022 走看看