1

当我发送 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" }
4

1 回答 1

5

您的 JSON 字符串格式不正确。对象键需要用引号括起来。

{
    "deliverySessionId":"c1fb327b-98a8-46d4-9e82-ce7507b5be93",
    "imageNames": ["name1", "name2"]
}
于 2013-04-22T20:44:46.973 回答