当String请求post params值变为null并显示错误
NetworkDispatcher.run:未处理的异常java.lang.NullPointerException:尝试在空对象引用上调用虚方法'int java.lang.String.length()'
我已完成调试,其中一个值为null。 这是我的代码,
public void getResponsePOST(Activity activity, final String[] name,
final String[] value) {
final CustomProgressBar pDialog = new CustomProgressBar(activity,R.drawable.loading);
//pDialog.setMessage("Loading...");
pDialog.show();
String tag_json_obj = "string_req";
System.out.println("URL PRODUCT"+mRequestUrl);
// RequestQueue queue = Volley.newRequestQueue(activity);
StringRequest sr = new StringRequest(Request.Method.POST, mRequestUrl,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
// Log.v("LOG", "9122014 " + response);
mResponseListener.responseSuccess(response.toString());
pDialog.dismiss();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// Log.v("LOG", "9122014 " + error);
VolleyLog.d(TAG, "Error: " + error.getMessage());
mResponseListener.responseFailure(error.getMessage());
pDialog.dismiss();
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
for (int i = 0; i < name.length; i++) {
try
{
params.put(name[i], value[i]);
}
catch(Exception e)
{
}
//System.out.println("Names:"+name[i]);
//System.out.println("Values:"+value[i]);
}
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("Content-Type", "application/x-www-form-urlencoded");
return params;
}
};
//Setting Timout Parameter : Bibin
sr.setRetryPolicy(new DefaultRetryPolicy(1800 * 1000,DefaultRetryPolicy.DEFAULT_MAX_RETRIES , DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
// Adding request to request queue
AppController.getInstance().addToRequestQueue(sr, tag_json_obj);
}
如何解决这个问题?
答案 0 :(得分:0)
你必须尝试这个: -
docker-compose up -d