我尝试用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);但它作为%25XX而不是%XX发送到服务器字符。为什么会发生这种情况?
发布于 2015-01-29 22:41:46
我需要将实体添加为字符串,而不是列表:
String param="username"+username;
post.setEntity(new StringEntity(param));https://stackoverflow.com/questions/28215935
复制相似问题