To obtain a general map of parameter names and values for query and path parameters, use the following code:
@GET
public String get(@Context UriInfo ui) {
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
MultivaluedMap<String, String> pathParams = ui.getPathParameters();
}
The following method extracts header and cookie parameter names and values into a map:
@GET
public String get(@Context HttpHeaders hh) {
MultivaluedMap<String, String> headerParams = ui.getRequestHeaders();
Map<String, Cookie> pathParams = ui.getCookies();
}
In general, @Context can be used to obtain contextual Java types related to the request or response.
For form parameters, it is possible to do the following:
@POST
@Consumes("application/x-www-form-urlencoded")
public void post(MultivaluedMap<String, String> formParams) {
// Store the message
}
http://docs.oracle.com/cd/E19798-01/821-1841/gipzz/index.html
info about jax-rs applications here
http://docs.oracle.com/cd/E19798-01/821-1841/gipzz/index.html
No comments:
Post a Comment