accepting list of parameters of same key in vertx

2019-05-21 19:08发布

问题:

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?

I think the URI should like localhost:8081/myApi?personId=1&personId=2&personId=3

回答1:

FInally found it.

HttpServerRequest request = RoutingContext.request();
MultiMap params =  request.params();
List<String> param = params.getAll("personId");

Here you can get list of personId. URI be like

localhost:8081/myApi?personId=1&personId=2&personId=3



标签: java rest vert.x