Pawan
Pawan

Reputation: 1654

@PathParam value is always empty

I am trying to get the id from the url, but it 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 am just starting to learn webServices,So please bare if it is something silly that i have Overlooked.

Upvotes: 5

Views: 3119

Answers (2)

Pawan
Pawan

Reputation: 1654

I had imported the Pathparam from wrong package

import javax.websocket.server.PathParam;

it should have been

import javax.ws.rs.PathParam;

Upvotes: 30

Naveen
Naveen

Reputation: 535

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

Try to access your resource with correct uri

Upvotes: 1

Related Questions