users@jersey.java.net

Re: [Jersey] Media type extensions not working with PathParams

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 18 Feb 2010 09:36:25 +0100

On Feb 17, 2010, at 11:31 PM, Dário Abdulrehman wrote:

> The first of the following methods works fine when I invoke it with
> the Media Type extensions (.json, .rdf) i.e. GET /resource.json?
> tf=abc&search_type=xpto
> but the second returns a resource not found if I invoke it like GET /
> resource.json/abc/def;search_type=xpto
> The second only works without the .json extension
>

Media type suffix keys are only supported at the end of a URI path.

The second URI needs to be:

   GET /resource/abc/def.json;search_type=xpto

Paul.

> Any idea why this is happening?
>
> Thanks.
>
> @GET
> @Produces({MediaType.APPLICATION_JSON,
> MediaTypeExt.APPLICATION_RDF_XML})
> public Response doGet(@Context Request req,
> @QueryParam("tf") List<String> tfs,
> @QueryParam("search_type") String searchType) throws Exception {
>
> @GET @Path("{tf : .+}")
> @Produces({MediaType.APPLICATION_JSON,
> MediaTypeExt.APPLICATION_RDF_XML})
> public Response doGet2(@Context Request req,
> @PathParam("tf" List<PathSegment> tfs,
> @MatrixParam("search_type") String searchType) throws Exception {
>
>