我尝试发送字符串"Приветмир!"
String link = POST_URL;
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(link);
String xml ="?????? ???";
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("file", xml));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
Run Code Online (Sandbox Code Playgroud)
并通过PHP脚本保存:
if(!empty($_REQUEST['file'])){
$fp = fopen("C:\\windows\\temp\\1.xml", "w");
$mytext =$_POST["file"];
$test = fwrite($fp, $mytext);
fclose($fp);
Run Code Online (Sandbox Code Playgroud)
但是我得到了?????? ????? 在我的网络服务器上,我尝试使用utf编码重新打开文件,但它没有帮助.我该如何解决呢.
DjH*_*orn 16
StringEntity的UTF-8字符集.这些线路将起到作用:
httpPost.setEntity(new StringEntity(body, HTTP.UTF_8));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14146 次 |
| 最近记录: |