我想使用java.net.*
将java对象传递给HTTP POST参数? Object包含多个参数。
答案 0 :(得分:1)
尝试
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(REQUEST_URL);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
//put here in nameValuePairs request parameters
UrlEncodedFormEntity form;
form = new UrlEncodedFormEntity(nameValuePairs, "UTF-8");
form.setContentEncoding(HTTP.UTF_8);
httppost.setEntity(form);
HttpResponse response = httpclient.execute(httppost);