我正在遵循 http://spring.io/guides/gs/accessing-data-rest/ 上的指南,这就像这个的 hello world...GET 请求工作完美,但是在尝试 POST 时,他们建议(我正在使用 Rest Client Chrome 扩展),使用 json
{ "firstName" : "Frodo", "lastName" : "Baggins" }
我收到以下错误:
{
cause: {
cause: null
message: "Unrecognized token 'firstName': was expecting 'null', 'true', 'false' or NaN at [Source: org.apache.catalina.connector.CoyoteInputStream@29508db1; line: 1, column: 11]"
}
message: "Could not read JSON: Unrecognized token 'firstName': was expecting 'null', 'true', 'false' or NaN at [Source: org.apache.catalina.connector.CoyoteInputStream@29508db1; line: 1, column: 11]; nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'firstName': was expecting 'null', 'true', 'false' or NaN at [Source: org.apache.catalina.connector.CoyoteInputStream@29508db1; line: 1, column: 11]"
}
我该如何解决这个问题?为什么会发生这种情况?
发送请求时尝试验证是否有 Content-Type:application/json
我是一名优秀的程序员,十分优秀!