Pass array as parameter to JAX-RS resource

前端 未结 2 1911
刺人心
刺人心 2021-01-04 11:15

I have many parameters to pass to the server using JAX-RS.

Is there a way to pass or AarryList with the URL?

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-04 11:36

    We can get the Query parameters and corresponding values as a Map,

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public void test(@Context UriInfo ui) {
        MultivaluedMap map = ui.getQueryParameters();
        String name = map.getFirst("name");
        String age = map.getFirst("age");
        System.out.println(name);
        System.out.println(age);
    }
    

提交回复
热议问题