Overload path functions with different @QueryParams Overload path functions with different @QueryParams spring spring

Overload path functions with different @QueryParams


A resource is uniquely defined by its path, and not by its params. Two resources you defined have the same path. You can either define new paths for each of them like /myGet/entity, /myGet/, /myGet/differentParam; or use a single path as /myGet/ and check the query params as following:

@GET  @Produces(MediaType.APPLICATION_JSON)@TypeHint(TagSets.class)public Response getTagSets(@Context HttpServletRequest request){       ...       if (request.getParameterMap().isEmpty()) {           // then you have no query params, implement as there are no query params       } else {           String queryParam = request.getQueryString();           // check queryParam, and add another if else statements, implement       }       ...}


The only way is as described in the comments. You can use a single method which declares all query params and then based on values (exists or not), calls the correct method.

(Work around approach)If all you want is to expose a single endpoint with multiple query param to the client and code implementation doesn't matter, you can use interceptors. read the query param and modify URI to direct it to proper method.