Android,Volley post请求数据 发送参数到服务器传值进数据库 数据库增加了一列 但是相应字段的值为空 怎么回事?

慢羊羊的快发明 2016-01-06 05:03:31
前提:数据接口没错

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;
}
...全文
382 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
天蝎_alex_ 2016-09-02
  • 打赏
  • 举报
回复
哥们你搞那了没有。我这边。也遇到同样的问题。
小城故事丶 2016-06-02
  • 打赏
  • 举报
回复
楼主能不能告诉我 服务器端怎么接收啊?多谢了
a763817224 2016-01-07
  • 打赏
  • 举报
回复
1.接口url是否正确,2传给服务器json是否正确3,解析返回json内容,是否有东西

80,362

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧