我正在尝试使用以下代码在服务器上发布数据,但数据是针对一个字段发布的,只有其他字段发布为空。我的代码有什么问题。我需要在我的 android 应用程序中做任何其他更改吗?
public void postData(String name,String email,String mobile,String subject,String message,String url)
{
// Create a new HttpClient and Post Header
Log.i("name",name);
Log.i("email",email);
Log.i("subject",subject);
Log.i("mobile",mobile);
Log.i("url",url);
try {
// Add your data
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(5);
nameValuePairs.add(new BasicNameValuePair("name", subject));
nameValuePairs.add(new BasicNameValuePair("email",subject));
nameValuePairs.add(new BasicNameValuePair("mobile", subject));
nameValuePairs.add(new BasicNameValuePair("subject", subject));
nameValuePairs.add(new BasicNameValuePair("message", subject));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity=response.getEntity();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
我的代码有什么问题?