我是新手,我开始在网络中使用排球库,因此,每次我尝试请求时,它都会用HTML文档响应并在logcat中显示此错误:
/com.example.nasrmohamed.winners_ten_aux D/Volley: [146] BasicNetwork.logSlowRequests: HTTP response for request=<[ ] http://LocalHost/wini/public/api/get-question 0x64aedf11 NORMAL 1> [lifetime=4033], [size=5247], [rc=200], [retryCount=0]
com.example.nasrmohamed.winners_ten_aux/ques.response: <!DOCTYPE html>
这是我的请求方法:
public List<String> getQuestion(final String token){
String finalUrl=Constants.BaseUrl+Constants.QuestionEndpoint;
RequestQueue queue = Volley.newRequestQueue(context);
StringRequest postRequest = new StringRequest(Request.Method.POST, finalUrl,
new Response.Listener<String>()
{
@Override
public void onResponse(String response) {
// response
Log.d("ques.response",response);
}
},
new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error) {
// error
Log.d("ques.error.response",error.toString());
}
}
){
@Override
protected Map<String, String> getParams()
{
Map<String, String> params = new HashMap<String, String>();
params.put("token", token);
return params;
}
};
// handles the slow connection, i.e connection timeout //
//int socketTimeout = 5000; //5 seconds
RetryPolicy policy = new DefaultRetryPolicy(
0,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
postRequest.setRetryPolicy(policy);
queue.add(postRequest);
return questionArr;
}
有什么帮助吗?