2009-06-25 90 views

回答

8

为了详细说明@ DFA的答案替代品,我觉得这是不是指定每个资源的方法签名变简单了:

public class MyResource { 

    @Context 
    private HttpServletRequest httpRequest; 

    @GET 
    public Response foo() { 
    httpRequest.getContentType(); //or whatever else you want to do with it 
    } 
} 
+0

任何这当我尝试从Junit调用REST api时,上述方法不起作用。该请求为空。 – 2016-03-17 12:10:26

相关问题