Android,Volley post请求数据 发送参数到服务器传值进数据库 数据库增加了一列 但是相应字段的值为空 怎么回事?
前提:数据接口没错
private String addShopCar(){
//连接网络并发送数据
RequestQueue requestQueue=Volley.newRequestQueue(this);
Map<String, String> map=new HashMap<String, String>();
requestQueue.start();
map.put("type", addShopCarBean.getShopType());
map.put("imag", addShopCarBean.getShopUrl());
map.put("shopname", addShopCarBean.getShopName());
map.put("jiage", addShopCarBean.getShopNumber());
map.put("shuliang", addShopCarBean.getShopPrice());
JSONObject jsonObjectParms=new JSONObject(map);
JsonObjectRequest jsonObjectRequest=new JsonObjectRequest(
Request.Method.POST, "http://192.168.1.105/APP/app_gouwuche/index.php", jsonObjectParms,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
})
//解析返回的Json数据
{
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
try {
JSONObject jsonObject=new JSONObject(new String(response.data,
"UTF-8"));
System.out.println(new String(response.data,
"UTF-8"));
return Response.success(jsonObject, HttpHeaderParser.parseCacheHeaders(response));
} catch (UnsupportedEncodingException e) {
return Response.error(new ParseError(e));
} catch (JSONException e) {
return Response.error(new ParseError(e));
}
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json; charset=UTF-8");
return headers;
}
};
requestQueue.add(jsonObjectRequest);
String personCar=map.get("result");
return personCar;
}