Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@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.

like image 317
Pawan Avatar asked Apr 17 '15 12:04

Pawan


2 Answers

I had imported the Pathparam from wrong package

import javax.websocket.server.PathParam;

it should have been

import javax.ws.rs.PathParam;
like image 63
Pawan Avatar answered Oct 01 '22 11:10

Pawan


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

Try to access your resource with correct uri

like image 31
Naveen Avatar answered Oct 01 '22 10:10

Naveen