【发布时间】:2016-03-16 12:09:53
【问题描述】:
private void login(){
// Post params to be sent to the server
Map<String, String> params = new HashMap<String, String>();
params.put("user_id", username);
params.put("password", password);
JsonObjectRequest req = new JsonObjectRequest(login_URL, new JSONObject(params),
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
VolleyLog.v("Response:%n %s", response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.e("Error: ", error.getMessage());
}
}){
/**
* Passing some request headers
* */
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=utf-8");
return headers;
}
};
// add the request object to the queue to be executed
AppController.getInstance().addToRequestQueue(req);}
我收到以下错误: E/Volley:[1] 10.onErrorResponse:错误:
不知道哪里出了问题
json 作为邮件发送: { "":"", "":"", "":"", } json 响应为: {"":""}
【问题讨论】:
-
详细地发布你的错误。
-
只是“E/Volley: [1] 10.onErrorResponse: Error:”
-
但没有描述错误。只是错误吗?使用日志获取错误..
-
关于json格式的response,服务器必须返回json格式的response
-
我只是注意到它正在工作,但有时返回“E/Volley:[1] 10.onErrorResponse:错误:”或“D/Volley:[218] BasicNetwork.logSlowRequests:HTTP 响应请求=
标签: android json post android-volley