Sha*_*era 5 java post android arraylist httpurlconnection
我正在使用DavidWebb来发出Http POST请求.我有所有要发送的参数的ArrayList或HashMap.如何使用DavidWebb传递一系列参数?
现在我这样做
Response<String> resp = webb
.post(Constants.URL + Constants.CUSTOMER_SIGNUP)
.param("username", params.get("username"))
.param("user_contact_no", params.get("user_contact_no"))
Run Code Online (Sandbox Code Playgroud)
我想做点什么
Response<String> resp = webb
.post(Constants.URL + Constants.CUSTOMER_SIGNUP)
.arraylist/hasmap of params
Run Code Online (Sandbox Code Playgroud)
params不熟悉特定的库,如果它是 a ,您可以只迭代其条目集HashMap:
Response<String> resp = webb
.post(Constants.URL + Constants.CUSTOMER_SIGNUP);
for (Map.Entry<String, String> entry : params.entrySet()) {
resp = resp.param(entry.getKey(), entry.getValue());
}
Run Code Online (Sandbox Code Playgroud)