users@jersey.java.net

[Jersey] _at_PathParam doesn't inject in property field

From: sdellafiore <stefano.dellafiore_at_gmail.com>
Date: Wed, 26 Aug 2009 09:23:11 -0500 (CDT)

Hi all,

I'm an happy user of jersey 1.1, but I'm having some problems using the
@PathParam annotation.
According to the @PathParam annotation, it should work with parameters,
fields and methods, but I'm able to make it work with parameters only.

I give 2 code fragments as an example:


1)
@Path("channel")
@Produces("application/javascript")
@PerRequest
public class ChannelResource {

    @GET
    @Path("/{channel}/popular/items")
     public JSONWithPadding getPopularItems(
            @DefaultValue("ever")
            @QueryParam("timespan") String timespan,
            @PathParam("channel") String channel) {

        ...
    }
}


2)
@Path("channel")
@Produces("application/javascript")
@PerRequest
public class ChannelResource {
    @PathParam("channel")
    private String channel;

    @GET
    @Path("/{channel}/popular/items")
     public JSONWithPadding getPopularItems(
            @DefaultValue("ever")
            @QueryParam("timespan") String timespan) {

        ...
    }

}



When I call http:////channel/local/popular/items

the code in 1) works properly, and the "channel" method parameter is given
the value "local". The code in 2) doesn't extract channel value (the channel
property stays is set to null).

Am I doing something wrong?



-- 
View this message in context: http://n2.nabble.com/PathParam-doesn-t-inject-in-property-field-tp3515081p3515081.html
Sent from the Jersey mailing list archive at Nabble.com.