Android 如何将编码设置为Http Post请求
如何将Android 如何将编码设置为Http Post请求,android,character-encoding,http-headers,Android,Character Encoding,Http Headers,如何将UTF编码设置为httppost请求 这是我的代码片段 HttpClient httpClient = getNewHttpClient(); String user_agent = (String) httpClient.getParams().getParameter( CoreProtocolPNames.USER_AGENT) + " Android"; httpClient.getParams().setParam
UTF
编码设置为httppost
请求
这是我的代码片段
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);
您可以通过调用
post.setHeader(“标题名”、“标题值”)代码>
你的情况应该是这样的
post.setHeader(“接受字符集”、“utf-8”)代码>它处理了这个请求;