我尝试使用httpPost将数据发送到服务器。 看起来像这样:
String username = URLEncoder.encode("myUsername","windows-1255");
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("****");
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("username", username));
post.setEntity(new UrlEncodedFormEntity(pairs));
HttpResponse response = client.execute(post);
但它发送到服务器char为%25XX而不是%XX。 为什么会这样?
答案 0 :(得分:0)
我需要将实体添加为字符串而不是列表:
String param="username"+username;
post.setEntity(new StringEntity(param));