//Post请求数据
private void postInfo() { RequestQueue requestQueue = Volley.newRequestQueue(MainActivity.this); StringRequest stringRequest = new StringRequest(Request.Method.POST, mPostUrl, new Response.Listener() { @Override
public void onResponse(String response) {
mText.setText(response); } }, new Response.ErrorListener() {
@Override
public void onErrorResponse(
VolleyError error) { } }) { //因为是POST请求,构造方法里面没有参数 他们给封装到了构造方法后边
@Override
protected MapgetParams() throws AuthFailureError { Mapmap = new HashMap();
map.put("userName", "lxx");
map.put("passWord", "123");
return map;
}
};
requestQueue.add(stringRequest);
}
网友评论