如果我们需要使用Map
@PostMapping("/abc/aa/{type}")
private final ResponseEntity<Void> invoke(@PathVariable String type,
@RequestParam(name = "params", required = false) Map<String, Object> params)
{
}
Curl 命令如下:
curl -G -X POST --url http://localhost:8585/abc/aa/default_aa.TEST_varchar100_94946640?params='apiTriggered=true;fromPk=7898989898'
但它抛出错误:
{"success":false,"header":null,"data":null,"messageKey":"error.500","message":"error.500","errors":[],"exceptions":[{"messageData":{},"resource":"Throwable","messageKey":"Throwable","message":"Internal exception was caught and handled by CustomErrorController (see logs for the trace); UID: ad4e6165-7eed-4682-b587-bca6a6b2532e; message: org.springframework.web.method.annotation.MethodArgumentConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'java.util.Map'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.util.Map': no matching editors or conversion strategy found","stackTrace"
any samples for a REST API with Map as a parameter - and curl command for the same will help me.
我尝试传递如下参数:
curl -G -X POST --url http://localhost:8585/abc/aa/default_aa.TEST_varchar100_94946640?apiTriggered=true&fromPk=7898989898
params(map) 未保存这些值,map 显示为 null。
有些人关闭了问题,在关闭之前请提及需要哪些额外信息。
CURL命令发送json
curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' http://localhost:8000?param1=value1¶m2=value2
将param1和Value1替换为查询参数的key和value 替换json数据值的key&value
欲了解更多信息,请参阅 如何使用 CURL 从命令行发出 API 请求