javaでpostした時のレスポンスが受け取れません。どうすれば良いのでしょうか。
以下ソースです。
public
1 HttpClient client = new DefaultHttpClient(); 2 HttpPost post = new HttpPost("url"); 3 4 ArrayList<NameValuePair> value = new ArrayList<NameValuePair>(); 5 value.add( new BasicNameValuePair("id","id")); 6 value.add( new BasicNameValuePair("pass","pass")); 7 String data =null; 8 9 try { 10 post.setEntity(new UrlEncodedFormEntity(value,HTTP.UTF_8)); 11 HttpResponse response = client.execute(post); 12 HttpEntity entity = response.getEntity(); 13 data = EntityUtils.toString(entity,HTTP.UTF_8); 14 System.out.println("response: "+data); 15 16 17 } catch (IOException e) { 18 e.printStackTrace(); 19 } 20 client.getConnectionManager().shutdown(); 21 } 22 } 23
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。