@PathParam is always empty

I am trying to get the id from the url but it is always empty.

  @Path("/{id}")
  @GET
  @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  public Client returnXmlClient(@PathParam("id") String id) 
  {
     logger.log(Level.SEVERE, "value of id is={0} ", id);
     // ... other code

I'm just starting to learn webServices, so please tell me if this is something stupid that I missed.

+4
source share
2 answers

I imported Pathparamfrom the wrong package

import javax.websocket.server.PathParam;

he should have been

import javax.ws.rs.PathParam;
+18
source

You are missing this annotation at the @Consumes method level (MediaType.XXXXX)

Try accessing your resource with the correct uri

0
source

All Articles