【发布时间】:2015-05-14 11:21:06
【问题描述】:
我正在使用Volley 库从Android 设备发送POST 查询以及字符串数据。
但是,服务器只接收null 参数值。我的代码是这样的:
final String param1 = "one";
final String param2 = "124843";
final String param3 = "878942";
final String param4 = "885942";
String url = getIPAddr()+":"+getPort()+"/com.va.jersey.helloworld/hello";
RequestQueue queue = Volley.newRequestQueue(getBaseContext());
StringRequest stringRequest = new StringRequest(Request.Method.POST,url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
showOutput(response);
}
},new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
showOutput(error.toString());
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("param1", param1);
params.put("param2", param2);
params.put("param3", param3);
params.put("param3", param4);
return params;
} //attaching POST params
};
queue.add(stringRequest);
我认为StringRequest有错误,请更正...
【问题讨论】:
标签: android http-post android-volley