I have a class that annotates using @Path as follows:
@Path("widgets") @Produces(MediaType.APPLICATION_XML) public class WidgetResource { @GET public Response getWidgets(@QueryParam("limit")) {
When I run the test client, localhost / widgets displays as expected, but when the getWidgetById method maps to localhost/widgets/widget/{id} . This is not what I want - I would like to have localhost/widgets and localhost/widget/{id}
I tried to exclude @Path annotation at the class level, but this prevents Jersey from recognizing this class as a REST resource (I tried both ScanningResourceConfig and ClassNameResourceConfig ) - both could not load the class as a resource if there was no @Path at the class level).
I assume that a (ugly) workaround would be to split the methods between the classes of the WidgetResource and WidgetsResource . I think this is a terrible decision, since both of these methods share resources in the same class, but I really need REST-ful localhost/widget (for one object) and localhost/widgets (for plural).
I missed something - do I have a way for Jersey to take the class as a resource class if @Path simply annotates the methods (I couldnโt get it working), if I canโt get the absolute display ( @Path(/widget/{id}) ) or some relative mapping ( @Path(../widget/id ) - none of these works are really just an analogy of what I need. Thanks!
cschooley
source share