7
我需要發送一個列表/整數值數組與改造到服務器(通過POST) 我做這種方式:如何發送陣列/列表與改造
@FormUrlEncoded
@POST("/profile/searchProfile")
Call<ResponseBody> postSearchProfile(
@Field("age") List<Integer> age
};
,並把它像這樣的:
ArrayList<Integer> ages = new ArrayList<>();
ages.add(20);
ages.add(30);
ISearchProfilePost iSearchProfile = gsonServerAPIRetrofit.create(ISearchProfilePost.class);
Call<ResponseBody> call = iSearchProfile.postSearchProfile(
ages
);
的問題是,該數值達到服務器不是逗號分隔。所以這裏的數值就像年齡:2030年而不是年齡:20,30。
我讀(例如這裏https://stackoverflow.com/a/37254442/1565635),一些寫有[]參數類似於數組取得了成功,但只導致所謂年齡[]參數2030。 我也試過使用數組以及帶有字符串的列表。同樣的問題。一切都直接來自一個條目。
那麼我該怎麼辦?
好,但是這將我的對象爲身體,但並不像其他領域中的一個「陣列」。或者不是嗎? –
查看更新回答 –
完全解決了我的問題(y) –