import net.sf.json.JSONObject; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.protocol.HTTP; String url = "http://127.0.0.1:8080/Test/mytest.do"; JSONObject jsonObj = new JSONObject(); jsonObj.put("aaa", "aaa"); jsonObj.put("bbb", "bbb"); try { HttpPost httpPost = new HttpPost(url); StringEntity entity = new StringEntity(jsonObj.toString(), HTTP.UTF_8); entity.setContentType("application/json"); httpPost.setEntity(entity); HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(httpPost); } catch (Exception e) { e.printStackTrace(); }