android okhttp+Retrofit 发送带有/ ^等特殊字符返回400

 步骤一:

 
  
Observable getMsg(
        @Query("content") String content,      
);
Observable getMsg(
        @Query(value = "content", encoded = true) String content,      
);
步骤二:
对content进行手动编码:
 
  
URLEncoded(content);
public static String URLEncoded(String paramString) {
        if (TextUtils.isEmpty(paramString)) {
            return "";
        }
        try {
            String str = new String(paramString.getBytes(), "UTF-8");
            str = URLEncoder.encode(str, "UTF-8");
            return str;
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

你可能感兴趣的:(Android,android)