android url 中文请求,乱码解决
2013-05-25 14:30
381 查看
private String connServerForResult(String url) { String strResult = ""; try { HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(); httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded"); httpPost.setURI(new URI(url)); //httpPost,通过urlParam添加请求参数 List < NameValuePair > urlParam = new ArrayList < NameValuePair > (); //中文内容,通过URLDecoder.decode转码 urlParam.add(new BasicNameValuePair("date", URLDecoder.decode(date_search.getText().toString(), "utf-8"))); httpPost.setEntity(new UrlEncodedFormEntity(urlParam, HTTP.UTF_8)); HttpResponse response = httpClient.execute(httpPost); HttpEntity entity = response.getEntity(); if (entity != null) strResult = EntityUtils.toString(entity, HTTP.UTF_8); } catch (Exception e) { // } return strResult; }
相关文章推荐
- android url 中文请求,乱码解决
- 解决URL请求的中文乱码问题
- 解决HttpURLConnection请求时传中文参数乱码问题
- Android中文URL乱码问题 解决
- 利用jQuery 解决URL请求参数有中文时出现乱码的问题
- android url中中文参数乱码问题的解决
- Javascript escape 解决 Jquery Ajax 异步请求 URL中文传参乱码问题 一般处理程序Handler获取参数
- Java HttpURLConnection模拟请求Rest接口解决中文乱码问题
- android 客户端发服务器发送中文请求,服务端是乱码的解决方法
- Java HttpURLConnection模拟请求Rest接口解决中文乱码问题
- 解决URL请求中的中文乱码问题
- android中文请求乱码彻底解决
- [置顶] Android http get请求里中文是乱码的解决(其中一种情况)
- Android 发送get请求 URL中文参数显示问号的一种解决办法
- Android向远程发服务请求中文乱码解决方法--全部代码经验证-方法一
- Android url中文乱码问题及解决办法
- 解决JSP URL请求中文乱码问题方法
- 关于backbone url请求中参数带有中文存入数据库是乱码的快速解决办法
- Android HTTP请求中文乱码解决
- Java Url请求方式中文乱码问题解决办法