HttpClient POST 的 UTF-8 編碼問題

 HttpClient client = new HttpClient();
    //PostMethod post=new PostMethod(IMUSERURL);
    ImPost post=new ImPost(IMUSERURL);
   
   
    NameValuePair[] data = {
            new NameValuePair("user.username", "hhhhhssss"),
            new NameValuePair("user.nickname", "隱隱約約隱隱約約擁有")
          };
          post.setRequestBody(data);
         
          try {
   client.executeMethod(post);
  } catch (HttpException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }

 

  public static class ImPost extends PostMethod{
   public ImPost(String url){
    super(url);
   }
   @Override
   public String getRequestCharSet(){
    return "UTF-8";
   }
  }

發佈了68 篇原創文章 · 獲贊 0 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章