java - 请问OkHttp 3如何设置post请求的编码呢?
ringa_lee
ringa_lee 2017-04-17 17:34:56
0
1
528

这是create方法的源码:

public static RequestBody create(MediaType contentType, String content) {
    Charset charset = Util.UTF_8;
    if (contentType != null) {
      charset = contentType.charset();
      if (charset == null) {
        charset = Util.UTF_8;
        contentType = MediaType.parse(contentType + "; charset=utf-8");
      }
    }
    byte[] bytes = content.getBytes(charset);
    return create(contentType, bytes);
  }

这个content是类似于“a=88&b=99”这样的字符串吗?

ringa_lee
ringa_lee

ringa_lee

모든 응답(1)
迷茫

推荐你使用 postman ,这个是 chrome 的一款http调试的插件,他可以直接生成okhttp 的代码。
这是我自己调试时用 postman生成的okhttp 的java代码。

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!