国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
微信支付:body不是utf8編碼

主要涉及到中文的位置:

  1. String body = "謝彬測(cè)試微信支付0.01_2";  
  2. String detail = "謝彬0.01_元測(cè)試開始";  
  3. String attach = "備用參數(shù),先留著,后面會(huì)有用的";  


不光有中文還有下劃線,在“統(tǒng)一下單”的時(shí)候,一直提示:body不是utf8編碼



網(wǎng)上各種iso8859-1的轉(zhuǎn)換說(shuō)明,我只想說(shuō),每個(gè)人的代碼都不一樣,不能拿來(lái)直接用!?。。?/p>

我的貌似是另外一個(gè)地方編碼出了問(wèn)題 http://bbs.csdn.net/topics/391022204,以下是關(guān)鍵部分代碼:

  1. /** 
  2.      * post請(qǐng)求并得到返回結(jié)果 
  3.      * @param requestUrl 
  4.      * @param requestMethod 
  5.      * @param output 
  6.      * @return 
  7.      */  
  8.     public static String httpsRequest(String requestUrl, String requestMethod, String output) {  
  9.         try{  
  10.             URL url = new URL(requestUrl);  
  11.             HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();  
  12.             connection.setDoOutput(true);  
  13.             connection.setDoInput(true);  
  14.             connection.setUseCaches(false);  
  15.             connection.setRequestMethod(requestMethod);  
  16.             if (null != output) {  
  17.                 OutputStream outputStream = connection.getOutputStream();  
  18.                 outputStream.write(output.getBytes("UTF-8"));  
  19.                 outputStream.close();  
  20.             }  
  21.             // 從輸入流讀取返回內(nèi)容  
  22.             InputStream inputStream = connection.getInputStream();  
  23.             InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");  
  24.             BufferedReader bufferedReader = new BufferedReader(inputStreamReader);  
  25.             String str = null;  
  26.             StringBuffer buffer = new StringBuffer();  
  27.             while ((str = bufferedReader.readLine()) != null) {  
  28.                 buffer.append(str);  
  29.             }  
  30.             bufferedReader.close();  
  31.             inputStreamReader.close();  
  32.             inputStream.close();  
  33.             inputStream = null;  
  34.             connection.disconnect();  
  35.             return buffer.toString();  
  36.         }catch(Exception ex){  
  37.             ex.printStackTrace();  
  38.         }  
  39.   
  40.         return "";  
  41.     }  

調(diào)用:

  1. //構(gòu)造xml參數(shù)  
  2.             String xmlInfo = HttpXmlUtils.xmlInfo(unifiedorder);  
  3.               
  4.             System.out.println(xmlInfo);  
  5.               
  6.             String wxUrl = UnifiedorderUrl;  
  7.               
  8.             String method = "POST";  
  9.               
  10.             String weixinPost = HttpXmlUtils.httpsRequest(wxUrl, method, xmlInfo).toString();  
  11.               
  12.             System.out.println(weixinPost);  



本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
JavaSocket短連接實(shí)現(xiàn)分別接收字符串和16進(jìn)制數(shù)據(jù)
JAVA 中的IO流
基于Tcp協(xié)議的簡(jiǎn)單Socket通信實(shí)例(JAVA)
Java獲取http和https協(xié)議返回的json數(shù)據(jù)
JAVA:IO流 之 節(jié)點(diǎn)流與處理流(2)
Android中文亂碼徹底解決
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服