SpringMVC 中向後臺傳入json數據報錯

報錯信息:spring

org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Unrecognized token 'XXXXXX': was expecting ('true', 'false' or 'null')

緣由: 提交form時候用錯了方法。 錯誤:code

data : $("#XXXXXForm").serialize(),

正確:orm

data : toJson($("#XXXXXXForm")),

增長下面方法:token

function toJson($form) {
    var data = {};
    $($form.serializeArray()).each(function(i, v) {
        data[v.name] = v.value;
    });
    return JSON.stringify(data);
};
相關文章
相關標籤/搜索