1

httpclient 応答ハンドラーを実装しています。行われている呼び出しはpostこのようなものです

result = httpclient.execute(httppost, responsehandler);

今、私は自分の応答ハンドラーを実装したいと考えています。応答のステータス コードを取得できるようにします。ステータス コード、つまり 200、404、403 のみに関心があり、この応答をint値として送り返したい

何かのようなもの

public class MyResponseHandler implements ResponseHandler<Integer> {

    public Integer handleResponse(HttpResponse respons) throws ClientProtocolException, IOException {
        // TODO Auto-generated method stub
        return 0;
    }

response.getStatusCode()問題は、応答オブジェクトにメソッドが表示されないことです。WS 呼び出しのステータス コードを取得する方法は?

4

1 に答える 1

1

を使用しresponse.getStatusLine().getStatusCode()ます。

于 2012-04-16T21:23:12.547 に答える