首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

解决android http请求带汉语言参数会乱码(url编码)

2012-09-27 
解决android http请求带中文参数会乱码(url编码)今天在用android 的?URL url new URL(http://www.my400

解决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();

热点排行