@@ -0,0 +1,2744 @@
+package com.joejoe.testcase.mytestcase;%0A%0Aimport android.support.v7.app.ActionBarActivity;%0Aimport android.os.Bundle;%0Aimport android.util.Log;%0Aimport android.view.View;%0A%0Aimport org.apache.http.HttpEntity;%0Aimport org.apache.http.HttpResponse;%0Aimport org.apache.http.HttpStatus;%0Aimport org.apache.http.NameValuePair;%0Aimport org.apache.http.client.entity.UrlEncodedFormEntity;%0Aimport org.apache.http.client.methods.HttpPost;%0Aimport org.apache.http.impl.client.DefaultHttpClient;%0Aimport org.apache.http.message.BasicNameValuePair;%0Aimport org.apache.http.params.BasicHttpParams;%0Aimport org.apache.http.params.HttpConnectionParams;%0Aimport org.apache.http.protocol.HTTP;%0Aimport org.apache.http.util.EntityUtils;%0A%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0A%0A/**%0A * %E7%A4%BA%E4%BE%8B%E5%8F%91%E9%80%81JSON%E6%95%B0%E6%8D%AE%E5%88%B0%E6%9C%8D%E5%8A%A1%E7%AB%AF%0A * @author joejoeZ%0A *%0A */%0A%0Apublic class SampleSendJSONDataToServer extends ActionBarActivity implements View.OnClickListener %7B%0A%0A    private static final String path = %22http://192.168.11.101:8080/Test/httpClientRequest.do%22;%0A%0A    @Override%0A    protected void onCreate(Bundle savedInstanceState) %7B%0A        super.onCreate(savedInstanceState);%0A        setContentView(R.layout.activity_http_client_get_response);%0A    %7D%0A%0A    @Override%0A    public void onClick(View v) %7B%0A        getRequest();%0A    %7D%0A%0A    private void getRequest() %7B%0A%0A        new Thread() %7B%0A%0A            @Override%0A            public void run() %7B%0A                HttpPost httpPost = new HttpPost(path);%0A                BasicHttpParams httpParams = new BasicHttpParams();%0A                HttpConnectionParams.setConnectionTimeout(httpParams, 3000);%0A                HttpConnectionParams.setSoTimeout(httpParams, 5000);%0A                DefaultHttpClient httpClient = new DefaultHttpClient(httpParams);%0A                ArrayList%3CNameValuePair%3E requestParams = new ArrayList%3CNameValuePair%3E();%0A                String jsonStr = %22%7Bname:joejoe, age:21, sex:male%7D%22;%0A                requestParams.add(new BasicNameValuePair(%22data%22, jsonStr));%0A%0A                try %7B%0A                    httpPost.setEntity(new UrlEncodedFormEntity(requestParams, HTTP.UTF_8));%0A                    HttpResponse response = httpClient.execute(httpPost);%0A                    int statusCode = response.getStatusLine().getStatusCode();%0A%0A                    if (statusCode == HttpStatus.SC_OK) %7B%0A                        HttpEntity entity = response.getEntity();%0A                        String content = EntityUtils.toString(entity);%0A                        Log.d(%22content%22, content);%0A                    %7D%0A                %7D catch (IOException e) %7B%0A                    e.printStackTrace();%0A                %7D finally %7B%0A                    httpClient.getConnectionManager().shutdown();%0A                %7D%0A            %7D%0A        %7D.start();%0A    %7D%0A%7D%0A

send json