【发布时间】:2015-01-29 13:27:12
【问题描述】:
我尝试使用 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 的形式发送到服务器字符。 为什么会这样?
【问题讨论】:
-
它是 %。更多bla bla bla
-
这不是答案。每个 %## 代表一个 url 编码字符。请了解。请准确说出您发送的字符串和收到的字符串。
-
我的意思是解码后%是%25
-
不要先对用户名进行编码,因为所有用户名都将使用 new UrlEncodedFormEntity() 进行编码。
-
我需要这样做,因为我将它作为字符集 windows-1255 发送。无论如何我找到了解决方案。感谢您的帮助
标签: android http-post httpclient