我想在改造中添加重复的密钥参数。 例如:https://www.google.co.in/?gfe_rd=cr&ei=1&ei=2&ei=3&ei=4&ej=1&ej=2&ej=3&ek=1&ek=2&ek=3&el=1&el=2&el=3。
这些关键参数是动态添加的。 如何解决这个问题。 请帮忙。 提前致谢。
答案 0 :(得分:0)
您可以使用ArrayList
之类的;
Call<YourResponseType> yourFunc(@Query("gfe_rd") String value, @Query("ei") ArrayList<String> eiValues, @Query("ej") ArrayList<String> eJvalues,...);
它会起作用;
http://yourUrl.com/gfe_rd=cr&ei=1&ei=2 ...
或者您可以使用path
和for
来完成。
String path = "/?";
for (int i = 0; i < yourQueryCount ; i ++ ){
if (i == 0)
path += "gfe_rd" + yourValue;
else if ( i < 5)
path += "ei=" + yourDynamicValueArrayForEi[i];
else if ( i < 7)
path += "ej=" + yourDynamicValueArrayForEj[i];
.
.
.
if (i < yourQueryCount-1)
path += "&";
}
并为您的改装功能提供这条路径;
@GET("{yourPath}")
Call<YourResponseType> yourFunc(@Path("yourPath") String path);