接受vertx api中相同键的参数列表 [英] accepting list of parameters of same key in vertx api
问题描述
如何在路由器 GET 方法中接受相同键中的参数列表.例如,我有一个查询参数名称为personId".但在获取请求中,可能有多个(列表)personId 即将到来.如何在 vertx.我在 HttpServerRequest
类中找不到任何这样的方法.我还有另一种选择来接受单个参数,但使用逗号分隔的 ID.但这不是错吗?没有别的办法了吗?
How to accept list of parameter in same key in router GET method.
e.g I have a query parameter name as 'personId'. but in get request there can be multiple(list of) personId are coming. How to handle this in vertx. I couldnt find any such method in HttpServerRequest
Class.
I have another option to accept single parameter but with comma separated ids. But isn't it wrong? Isn't there any other way?
我认为 URI 应该像 localhost:8081/myApi?personId=1&personId=2&personId=3
I think the URI should like localhost:8081/myApi?personId=1&personId=2&personId=3
推荐答案
终于找到了.
HttpServerRequest request = RoutingContext.request();
MultiMap params = request.params();
List<String> param = params.getAll("personId");
在这里你可以得到personId的列表.URI 就像
Here you can get list of personId. URI be like
localhost:8081/myApi?personId=1&personId=2&personId=3
这篇关于接受vertx api中相同键的参数列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!