2009-06-25 87 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

相關問題