Warm tip: This article is reproduced from stackoverflow.com, please click
java web-services

Access Request object from REST

发布于 2020-03-27 10:29:30

Is it possible to access the Request object in a REST method under JAX-RS?

I just found out

@Context Request request;
Questioner
qnoid
Viewed
38
83.8k 2015-09-04 20:06

On JAX-RS you must annotate a Request parameter with @Context:

 @GET  
 public Response foo(@Context Request request) {

 }

Optionally you can also inject: