gpt4 book ai didi

java - 如何将字符串 REST 与 JPA 连接?

转载 作者:太空宇宙 更新时间:2023-11-04 06:42:34 34 4
gpt4 key购买 nike

我正在遵循 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

关于java - 如何将字符串 REST 与 JPA 连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24481542/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com