返回
顶部

修改密码

首页 > 教程 > 网络通信 > HTTP > 正文
解决android http请求带中文参数出现乱码(url编码)

+1

-1

收藏

+1

-1

点赞0

评论0

今天在用Android的 URL url = new URL("http://www.android100.org/extend/search.php?sebox=学习"); HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); 传递到服务端的中文字符是乱码,最后是将要发送的字符经过编号就可以了,代码修改如…

今天在用Android的

 
URL url = new URL("http://www.android100.org/extend/search.php?sebox=学习");
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
 

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

URL url = new URL("http://wwwandroid100.org/extend/search.php?sebox="+java.net.URLEncoder.encode("学习"));
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();

扫一扫在手机打开

评论
已有0条评论
0/150
提交
热门评论
相关推荐
今日要闻
换一批
热点排行