我正在使用HttpPost通过php将arraylist值插入mysql但是我的mysql中有双重输入我在底部提到了我的代码
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://");
ResponseHandler<String> responseHandler=new BasicResponseHandler();
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("a", a.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("b", b.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("c", c.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("d", d.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("e", e.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("f", f));
nameValuePairs.add(new BasicNameValuePair("g", g));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
String responseBody = httpclient.execute(httppost, responseHandler);
Toast.makeText(getApplicationContext(), responseBody, Toast.LENGTH_SHORT).show();
Log.d("a", responseBody );
答案 0 :(得分:0)
您似乎正在执行httppost
两次。尝试删除该行
HttpResponse response = httpclient.execute(httppost);
据我所知,你没有使用response
。