Defining a @QueryParam
does not mean that this parameter is required. If the query-string is empty or not including the defined query-param the value of the parameter will be null
.
So both methods are ambiguous and seems like the first one wins. If you want two methods you can easily check for null
and call the other method.
@GET
public Response filterQuery(@QueryParam("filter") String filterQuery) {
if (filterQuery == null) {
return filter();
}
return Response.accepted("filter: " + filterQuery).build();
}
private Response filter() {
return Response.accepted("Hello world").build();
}