早上好,带有截击的字符串请求失败错误//-https://www.express.pk/world/archives/?page=1的意外响应代码404-//
RequestQueue queue = Volley.newRequestQueue(this);
StringRequest stringRequest = new StringRequest
("https://www.express.pk/world/archives/?page=1", new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d("check", "ok");
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
neonews();
Log.d("check", "fail");
}
});
queue.add(stringRequest);
答案 0 :(得分:0)
添加请求方法GET或POST 替换您的
StringRequest stringRequest = new StringRequest
("https://www.express.pk/world/archives/?page=1", new Response.Listener<String>()
使用
StringRequest stringRequest = new StringRequest
(Request.Method.GET,"https://www.express.pk/world/archives/?page=1", new Response.Listener<String>()
如果未获得成功响应,则转到错误响应 检查API是否具有将在API调用中传递的任何参数
答案 1 :(得分:0)