@DefaultValue

The @javax.ws.rs.DefaultValue annotation specifies a default value for the request parameters accessed using one of the following annotations: PathParam, QueryParam, MatrixParam, CookieParam, FormParam, or HeaderParam. The default value is used if no matching parameter value is found for the variables annotated using one of the preceding annotations.

The following REST resource method will make use of the default value set for the from and to method parameters if the corresponding query parameters are found missing in the URI path:

@GET 
@Produces(MediaType.APPLICATION_JSON) 
public List<Department> findAllDepartmentsInRange 
  (@DefaultValue("0")  @QueryParam("from") Integer from,  
    @DefaultValue("100")  @QueryParam("to") Integer to) { 
    findAllDepartmentEntitiesInRange(from, to); 
} 
..................Content has been hidden....................

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