2017-12-14 3 views
0

私はRESTサービスでテストしており、HttpServletResponseオブジェクトを取得する必要があります。HttpServletResponseの取得が安心なサービスで

私はこのような関数を呼び出す:私は欠けている何かが

http://localhost:8080/wsService/api/servicetest/testify

私が手HttpServletResponseは常に

@Path("/testify") 
@GET 
@Produces(MediaType.APPLICATION_JSON) 
public Response Testify(HttpServletResponse response) throws Exception { 
    try { 
     return Utilities.getSvc(true, "OK"); 

    } catch (Exception e) { 
     return Utilities.getSvc(false, "ERROR"); 
    } 
} 

nullですか?私は最終的にちょうどHttpServletResponseオブジェクトに@Context注釈を入れて、HttpServletRequestパラメータを追加するために必要な、それをやった

+1

を[これ](https://stackoverflow.com/questions/20937362/what-コンテキストアノテーションを使用してオブジェクトを挿入することができます)が役立つ可能性があります。 –

答えて

0

@Path("/testify") 
@GET 
@Produces(MediaType.APPLICATION_JSON) 
public Response Testify(@Context HttpServletResponse response, 
         @Context HttpServletRequest request) throws Exception { 
    try { 
     return Utilities.getSvc(true, "OK"); 

    } catch (Exception e) { 
     return Utilities.getSvc(false, "ERROR"); 
    } 
} 
関連する問題