如何在GET调用中将map(键值对)作为请求参数发送 [英] How to send map(key-value pair) as request parameter in a GET call
本文介绍了如何在GET调用中将map(键值对)作为请求参数发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在GET调用中将地图作为参数发送?我搜索了,我可以找到列表并设置集合.但是没有找到要收集地图的任何东西.
Is it possible to send map as parameter in a GET call.? i searched and i could find for list and set collection. But did not find anything for map collection.
我尝试了以下方法,我的控制器方法如下所示.
I tried the following, My controller method looks like this.
@GetMapping("/test")
public ResponseEntity<?> mapTest(@RequestParam Map<String,String> params) {
LOG.info("inside test with map "+ params );
return new ResponseEntity<String>("MAP", HttpStatus.OK);
}
我从邮递员发送了以下请求
And i sent the following request from postman
http://localhost:8080/test?params={a:abc,b:bcd}
一切正常,没有错误和异常.但是我收到的地图看起来像 key = params,value = {a:abc,b:bcd}
Everything works without errors and exceptions. But the map which i received looks like key=params , value={a:abc,b:bcd}
我希望收到的地图类似于 key1 ="a" value1 = abc,key2 ="b" value2 ="bcd"
I expected the received map to be like key1="a" value1=abc ,key2="b" value2="bcd"
推荐答案
查看全文