Home  >  Forum  >  Web Services
Post New Query

Difference between JAX-RS @PathParam and @QueryParam


joined on
March 27,2014
Asked on March 10,2015
What is difference between JAX-RS @PathParam and @QueryParam?
joined on
October 10,2013
Replied on April 17,2015

PathParam and @QueryParam both are the JAX-RS API.

PathParam can be used as 

/test/data/{id}/{name}

/test/123/Ram

@Path("/data/{id}/{name}")
        @Produces("text/plain")
public String add(@PathParam("id") Integer id, @PathParam("name") String name ){
          //ToDo
         return "result";
}

For more detail, find the URL



QueryParam can be used as 

/test/data?id=123&name=Ram

       @Path("/data/{id}/{name}")
        @Produces("text/plain")
public String add(@QueryParam("id") Integer id, @QueryParam("name") String name ){
          //ToDo
         return "result";
}

For more detail, find the URL.




joined on
October 14,2016
Replied on October 14,2016

DIFFERENCE BETWEEN PathParam and QueryParam: 

Query parameters are added to the url after the ? mark, while a path parameter is part of the regular URL.

In the URL below tom could be the value of a path parameter and there is one query parameter with the name id and value .

Write Answer








Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us