0

私のコードでは、サーバーへのリクエストを実行する行で IllegalArgumentException (インデックス 85 のクエリで不正な文字) をキャッチします。作業はパターンコマンドとしてビルドされ、別のタスクは正しく完了しますが、これは完了しません:

public CreateCommentTask(String barcodeId, String ball, String comment,
        String sign) {
    super(getApplicationUrl() + "?command=createComment" + "&barcodeId="
            + barcodeId + "&ball=" + ball + "&text=" + comment
            + "&sessionId=" + sign);
    // TODO Auto-generated constructor stub
}

したがって、アドレスと文字列形式のデータしかありません。次の行でアプリがクラッシュします。

HttpResponse response = client.execute(task.createRequest());

あなたはなにか考えはありますか?

4

2 に答える 2

2

パラメータ(おそらくcomment変数)をURLエンコードする必要があると思います。

編集:java.net.URIを使用して適切なクエリを生成できます。これを試して:

super(new URI(getApplicationUrl() + "?command=createComment" + "&barcodeId="
            + barcodeId + "&ball=" + ball + "&text=" + comment
            + "&sessionId=" + sign).toString());
于 2011-05-28T15:01:23.920 に答える
0

事前に文字列を作成してログに記録してみませんか? 次に、文字 85 が何であるかを確認できます。それがログに記載されている場合、問題があることを保証します。理由がわからない場合は、結果の文字列と残りのログを投稿してください。

public CreateCommentTask(String barcodeId, String ball, String comment,
        String sign) {
    String query = getApplicationUrl() + "?command=createComment" + "&barcodeId="
            + barcodeId + "&ball=" + ball + "&text=" + comment
            + "&sessionId=" + sign;
    Log.d("HOLYCRAP", query);
    super(query);
}
于 2011-05-31T11:11:41.340 に答える