解决方案 »

  1.   

    用的是GBK
    response.setCharacterEncoding("GBK");
      

  2.   

    用的是GBK
    response.setCharacterEncoding("GBK");
    那你android端转下gbk啊
      

  3.   

    用的是GBK
    response.setCharacterEncoding("GBK");
    那你android端转下gbk啊
    Android端改成这样么?String hello=response.getHeaders("hello")[0].getValue();
    hello=new String(hello.getBytes("GBK"));
    System.out.println(hello);输出这样:
    还是乱码
      

  4.   

    这个问题 你只能自己多debug, 才能比较深的理解编码。
    现在编码格式基本上用utf-8 .
      

  5.   

    用的是GBK
    response.setCharacterEncoding("GBK");
    那你android端转下gbk啊
    Android端改成这样么?String hello=response.getHeaders("hello")[0].getValue();
    hello=new String(hello.getBytes("GBK"));
    System.out.println(hello);输出这样:
    还是乱码可能是这样new String(hello.getBytes("gbk"),"iso8859");
    可以先用浏览器试试
      

  6.   

    用的是GBK
    response.setCharacterEncoding("GBK");
    那你android端转下gbk啊
    Android端改成这样么?String hello=response.getHeaders("hello")[0].getValue();
    hello=new String(hello.getBytes("GBK"));
    System.out.println(hello);输出这样:
    还是乱码可能是这样new String(hello.getBytes("gbk"),"iso8859");
    可以先用浏览器试试
    Android端的中文还是问号,因为header关键字是自定义的,所以浏览器打不开,提示页面有错
      

  7.   

    问题没解决,不过我换另一种方式了。网上大多只给出Android端或JavaWeb端其中之一。在这里贴上两端的代码:
    首先是Android端//先准备要发送的数据
    HttpPost httpPost = new HttpPost(new URI(url));
    List<NameValuePair> list=new ArrayList<NameValuePair>();
    JSONObject jso=new JSONObject();
    jso.put("name", "abc大家好123");
    list.add(new BasicNameValuePair("info", jso.toString()));
    httpPost.setEntity(new UrlEncodedFormEntity(list, "GBK"));
    //然后连接
    HttpClient client = new DefaultHttpClient();
    HttpResponse response = client.execute(httpPost);
    //获取回送的数据
    if (response.getStatusLine().getStatusCode() == 200) {// 200表示请求成功 HttpEntity entity = response.getEntity();
    if (entity != null) {
    String beanListToJson = EntityUtils.toString(entity, "GBK");
    System.out.println("receive:"+beanListToJson);
    return beanListToJson;
    }
    }
    接下来JavaWeb端代码://获取Android提交的数据
    HttpServletRequest request = ServletActionContext.getRequest();
    String s=request.getParameter("info");
    System.out.println(s);
    //向Android发送数据
    HttpServletResponse response = ServletActionContext.getResponse();
    response.setCharacterEncoding("GBK");
    response.getWriter().write(beanListToJson);//这个beanListToJson是个处理过的json字符串