I am new to java. I was looking the below code.
@Produces("text/xml")
@GET
@Path("/xml/search")
public Object searchXML(@QueryParam("query") String query,
@QueryParam("granularity") String granularity) {
return search(query, granularity);
}
I couldn't understand the uses of @Produces, @GET, @Path and @QueryParam before function definition in above code. Can anybody put some light on this. Thanks
Those anotations are defined by JAX-RS, a Standard for RESTful Web Services.
In the example above, it mean the method will handle a:
GET request
on path "/xml/search"
and map the query argument "query" to String query argument,
as well as the "granularity" to granularity
the resulting content-type will be "text/xml"
(and it will probably call a custom marshaller for this)
(see this page for a reference)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With