android volley 發送 POST 請求


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 中。

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM