how to send string by http post in UTF-8

前端 未结 2 906
萌比男神i
萌比男神i 2020-12-19 09:06

I try to send string \"Привет мир!\"

String link = POST_URL;
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(link);
String          


        
相关标签:
2条回答
  • 2020-12-19 09:44

    This worked for me:

    HttpPost httpPost = new HttpPost("http://someurl.com");
    httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair, HTTP.UTF_8));
    
    0 讨论(0)
  • 2020-12-19 09:55

    The StringEntity's charset to UTF-8. These lines will do the trick:

     httpPost.setEntity(new StringEntity(body, HTTP.UTF_8));
    
    0 讨论(0)
提交回复
热议问题