我正在使用 Square 的 Retrofit 库。我需要使用可变数量的参数来实现请求。我找到了建议(链接),我试试这个:
我改变
@GET("someURL")
void method(
@Query("firstParameter") int firstValue,
@Query("secondParameter") String secondValue,
Callback<Response> cb
);
至
@POST("someURL")
void method(
@Body Map<String, Object> parameters,
Callback<Response> cb
);
并使用以下:
final HashMap<String, Object> param = new HashMap<String, Object>();
param.put("firstParameter", firstValue);
param.put("secondParameter", secondValue);
第一种方法效果很好,但第二种方法不起作用。怎么了?