@GET

A RESTful system uses the HTTP GET method type for retrieving the resources referenced in the URI path. The @javax.ws.rs.GET annotation designates the method of a resource class to respond to the HTTP GET requests.

The following code snippet illustrates the use of the @GET annotation to make a method respond to the HTTP GET request type. In this example, the REST URI for accessing the findAllDepartments() method may look like /departments. The complete URI path may take the http://host:port/<context-root>/<application-path>/departments URI pattern:

//imports removed for brevity 
@Path("departments") 
public class DepartmentService { 
  @GET 
  @Produces(MediaType.APPLICATION_JSON) 
  public List<Department> findAllDepartments() { 
    //Find all departments from the data store 
    List<Department> departments = findAllDepartmentsFromDB(); 
    return departments; 
  } 
  //Other methods removed for brevity 
} 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.90.182