Home  >  Forum  >  Web Services
Post New Query

Difference between JAX-RS @PathParam and @FormParam?


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

@PathParam and @FormParam 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


@FormParam is used to access data from web request as form. Suppose we a form as  

     <form method="POST" action="/resteasyservice-1/employee/manage/save">
       Id:  <input type="text" name="id"/><br/>
        Name: <input type="text" name="name"/><br/>
        Company: <input type="text" name="company"/><br/>
        <input type="submit" value="Submit"/>
     </form>

We can use @FormParam as 

@Path("/save")
public String saveEmp(@FormParam("id") String id, @FormParam("name") String name, 
                         @FormParam("company") String company) {
    //TODO
    return "result";
}

Find the URL for the detail.







Write Answer








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