0

My Controller in jaxrs look like this

@GET
    @Path("/search/{index}/{type}")
    @Produces(MediaType.APPLICATION_JSON)
    public MapBiodivResponse list(
            @PathParam("index") String index, @PathParam("type") String type,
            @QueryParam("trait_8") String trait_8, @QueryParam("trait_9") String trait_9,
            @QueryParam("trait_10") String trait_10, @QueryParam("trait_11") String trait_11,
            @QueryParam("trait_12") String trait_12, @QueryParam("trait_13") String trait_13,
            @QueryParam("trait_15") String trait_15,
            @QueryParam("bottom") Double bottom,
            ){

            }

I wonder is that possible to collect all queryParams in jaxrs which have substring as trait and put that in Map. Something like this

@GET
    @Path("/search/{index}/{type}")
    @Produces(MediaType.APPLICATION_JSON)
    public MapBiodivResponse list(
            @PathParam("index") String index, @PathParam("type") String type,
            @QueryParam("trait.*") String trait_8, @QueryParam("trait.*") Map trait,
            @QueryParam("bottom") Double bottom,
            ){

            }

I know the way to get all the parameter using @Context, but i just want to collect few queryParams on the basis of basis of either regex or some wildcard character.

user2903536
  • 1,716
  • 18
  • 25
  • Possible duplicate of [How can I grab all query parameters in Jersey JaxRS?](https://stackoverflow.com/questions/5718575/how-can-i-grab-all-query-parameters-in-jersey-jaxrs) –  Mar 27 '18 at 12:30
  • @LutzHorn by using Context UriInfo uriInfo, String content u get all the queryParams i want only those who have "trait" in between – user2903536 Mar 27 '18 at 12:37
  • Yes, that should be easy. Check that the name of the query parameter starts with `trait`. –  Mar 27 '18 at 12:39

0 Answers0