当我发送 json 数组时,Spring 抛出一个错误。我不确定我在这里错过了什么。
请求体
{
"deliverySessionId":"c1fb327b-98a8-46d4-9e82-ce7507b5be93",
imageNames: ["name1", "name2"]
}
端点
@RequestMapping(value = { "/examImages/" }, method = { RequestMethod.POST } )
public @ResponseBody ImageResponseCommand streamExamImages( @RequestBody ImageResponseCommand imageResponseCommand ) {
错误
The request sent by the client was syntactically incorrect.
如果我的请求不包含 imageNames 属性,它工作正常。
{ "deliverySessionId":"c1fb327b-98a8-46d4-9e82-ce7507b5be93" }
最佳答案
您的 JSON 字符串格式不正确。对象键需要用引号引起来。
{
"deliverySessionId":"c1fb327b-98a8-46d4-9e82-ce7507b5be93",
"imageNames": ["name1", "name2"]
}
关于java - Spring 不会反序列化 json 字符串(不带引号的属性),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16156281/