步骤一:
Observable<ResultResponse> getMsg(
@Query("content") String content,
);Observable<ResultResponse> 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 "";
}
}
本文介绍了一种使用URL编码处理HTTP请求参数的方法。通过示例代码展示了如何手动对字符串进行URL编码,并将其作为查询参数传递给服务端。特别强调了在不同情况下使用@Query注解的不同方式。
1062

被折叠的 条评论
为什么被折叠?



