首页 > 解决方案 > 处理“curl ...-data”的Rest Endpoint

问题描述

我有一个 api,它应该可以像这样使用: curl ' http://localhost:8080/api/bla ' --data '{"comment":"something"}'。

因此,我创建了一个后端点,例如:

@RequestMapping(value = "/bla", produces = { "application/json" },       
                method = RequestMethod.POST)
public ResponseEntity<Token> getBla(@RequestParam  String comment){}

但我收到一个错误必需的字符串参数“注释”不存在 我也尝试添加

@RequestParam(value="comment", required=true) String comment

有同样的错误。你能帮我看看这里有什么问题吗?

标签: springformsrest

解决方案


推荐阅读