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");
    }
    });
    这样才能成功在后台接收到。

  • 相关阅读:
    pam_cracklib module
    转:ubuntu svn
    fw: subversion+apache config
    转:jenkins 简介
    fw:java 10大必知技术
    FW: Linux 搭建 csvn 服务器。
    转:修改svn 端口号
    转:Ubuntu搭建jenkins
    转:vmware workstation的三种网络连接方式。
    图像处理之直方图均衡
  • 原文地址:https://www.cnblogs.com/dqiii/p/13159460.html
Copyright © 2011-2022 走看看