Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3655

When Jersey cannot map a query parameter, it fails with 404, why so?

$
0
0

I'm not a Jersey guru but I read that Jersey cannot resolve Java methods based on query params, but it looks sometimes it does, here is my example.

This is the server code:

@GET@Path("/services")public String getAll(        @QueryParam("limit") Integer limit,        @QueryParam("offset") Integer offset){        return "1 2 3";}

And this is the client code:

ClientResponse response = webResource        .path("services")        .queryParam("limit", "ab")        .get(ClientResponse.class);logger.info(response.toString());assertEquals(response.getStatus(), 200);

It looks like Jersey doesn't like "ab" and isn't able to map the query param so it returns 404, however if limit = "1", i can hit the right method.

Is Jersey right to return 404 in this case? I know i could broaden the interface using String rather than Integer to override all the treatment for any feasible syntax error. Can I configure Jersey to do this on my behalf?

I'm using server: Grizzly/1.9.18, with Jersey 1.11


Viewing all articles
Browse latest Browse all 3655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>