简体   繁体   English

Feign 客户端未正确编码请求参数

[英]Feign client doesn’t encode request param correctly

I have a feign client with the following structure我有一个具有以下结构的假客户

Result getResult(@RequestParam String id, @RequestParam Map<String, Object> params)

Where the value in the map in the second argument can be of any primitive type (int, long) or object (String, BigDecimal).其中第二个参数中 map 中的值可以是任何原始类型(int、long)或 object(String、BigDecimal)。

Unfortunately, the values in the client request don't seem to be deserialized correctly on the server side.不幸的是,客户端请求中的值似乎没有在服务器端正确反序列化。 For instance, sending a Map.of(“userId”, 1234567893L) is parsed as “userId”->”1234567893L”, instead of “userId”->1234567893L.例如,发送Map.of(“userId”, 1234567893L)被解析为“userId”->“1234567893L”,而不是“userId”->1234567893L。 Is there a way to tell the objectmapper to parse Long values as expected?有没有办法告诉 objectmapper 按预期解析 Long 值?

Try using尝试使用

@QueryMap Map<String, Object> 

params instead of参数而不是

@RequestParam Map<String, Object> params)

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

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