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

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

关注公众号“大模型全栈程序员”回复“小程序”获取1000个小程序打包源码。更多免费资源在http://www.gitweixin.com/?p=2627

发表评论

邮箱地址不会被公开。 必填项已用*标注