gpt4 book ai didi

android httppost mysql 没有双重输入

转载 作者:行者123 更新时间:2023-11-30 00:03:24 24 4
gpt4 key购买 nike

我正在使用 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 );

最佳答案

您似乎执行了 httppost 两次。尝试删除该行

HttpResponse response = httpclient.execute(httppost);

据我所知,您没有使用response

关于android httppost mysql 没有双重输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24823027/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com