如何将UTF
编码设置为Http Post
请求?
这是我的代码片段。
HttpClient httpClient = getNewHttpClient();
String user_agent = (String) httpClient.getParams().getParameter(
CoreProtocolPNames.USER_AGENT)
+ " Android";
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
user_agent);
httpClient.getParams().setBooleanParameter(
"http.protocol.expect-continue", false);
HttpResponse response;
HttpPost post = new HttpPost(remoteUrl);
System.out.println("Url:" + remoteUrl + " values:"
+ nameValuePair.toString());
post.setEntity(new UrlEncodedFormEntity(nameValuePair));
response = httpClient.execute(post);
int postStatus = response.getStatusLine().getStatusCode();
String result = EntityUtils.toString(response.getEntity());
System.out.println("result:" + result);