繁体   English   中英

如何从邮递员发送 JSON 以获取自定义 VO

[英]How to send JSON from postman for a custom VO

我应该从 Postman 发送的 JSON 格式是什么才能正确地将它映射到我的 rest 控制器。

TfundsVO :
BigDecimal accountNum
String accountName
BigDecimal accountBal



@GetMapping("/")
public ResponseEntity<Object> getFunds(@RequestBody TfundsVO tfundsVO) {
    System.out.println(tfundsVO.getAccountNum());
}

使用的示例 JSON:

{
    "tfundsVO": [
     {
        "accountName": "Sam"
     } 
  ]
}

当我从 Postman 尝试上述 JSON 时,调用转到 getFunds 方法,但是 TfundsVO 中的所有值都是 NULL。

只需发送没有数组的有效负载

{ "account name": "test" }

并请添加一个 application/json 标头作为内容类型

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM