`
ljl_xyf
  • 浏览: 618466 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

解决android http请求带中文参数会乱码(url编码)

阅读更多

今天在用android 的

 URL url = new URL("http://www.my400800.cn &search=400电话 ");
  HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();

时传递到服务端的中文字符时乱码,最后是将要发送的字符经过编号就可以了代码修改如下:

 

 

 URL url = new URL("http://www.my400800.cn &search="+java.net.URLEncoder.encode("400电话 "));
  HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics