JSON PUT返回状态码400

时间:2014-07-21 07:54:15

标签: javascript put http-status-code-400

我必须发出PUT请求,但无论我尝试什么,我都会收到状态码400,这意味着"由于语法错误,无法满足请求。"我无法弄清楚问题出在哪里。这是请求部分(使用knockoutjs和dropwizard):

self.save = function(person){
    $.ajax("/testtest/hello-world?", {
        data: person,
        type: "PUT", 
        contentType: "application/json"
    });
};

它甚至无法到达servlet,据我所知,URL是正确的。 这是请求消息:

0:0:0:0:0:0:0:1 -  -  [21/Jul/2014:08:02:45 +0000] "PUT /testtest/hello-world? HTTP/1.1" 400 - "http://localhost:8080/testtest/assets/index.htm" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36" 19

和错误消息:

Unrecognized token 'name': was expecting 'null', 'true', 'false' or NaN

1 个答案:

答案 0 :(得分:0)

当我将其更改为

时,它有效
self.save = function(person){
    $.ajax({
        type: "PUT", 
        data: person,
        url : "/testtest/hello-world?",
    });
};