Map<String, String> params = new HashMap<String, String>();
params.put("fromUser", "lesliefang");
params.put("toUser", "xiaojun");

JsonObjectRequest newMissRequest = new JsonObjectRequest(
    Request.Method.POST, "http://127.0.0.1:8080/users",
    new JSONObject(params), new Response.Listener<JSONObject>() {

        @Override
        public void onResponse(JSONObject jsonobj) {
             
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
 
        }
    });

 volley 将 200 201 等视为成功的请求,而将  204 400 404 等视为失败的请求,会回调到 ErrorListener 中。

 

 

相关文章:

  • 2021-04-24
  • 2021-03-26
  • 2022-01-13
  • 2021-08-09
  • 2021-11-23
  • 2021-11-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
相关资源
相似解决方案