Anyone know how to get content of httprequest in REST webservice using java?
thanks
You can inject context about the individual requests. As an example, the code snippet below shows how the HTTP request headers can be injected.
@GET
@Produces{"text/plain"}
public String listHeaderNames(@Context HttpHeaders headers) {
StringBuilder buf = new StringBuilder();
for (String header: headers.getRequestHeaders().keySet()) {
buf.append(header);
buf.append("\n");
}
return buf.toString();
}
See the relevant part of the JAX-RS 1.1 specification for more information.
Look at Restlet
// Create the client resource
ClientResource resource = new ClientResource("http://www.restlet.org");
// Write the response entity on the console
resource.get().write(System.out);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.