我需要将参数发布到我的服务器上,似乎凌空无视我的参数并给我空值
这是我的代码:
StringRequest strReq = new StringRequest(Request.Method.POST,
url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Error: " + error.getMessage());
Toast.makeText(getApplicationContext(),
error.getMessage(), Toast.LENGTH_SHORT).show();
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("from", textfrom_btn);
params.put("to", textto_btn);
params.put("seat", seat);
Log.e(TAG, "Posting params: " + params.toString());
return params;
}
};
// Adding request to request queue
MyApplication.getInstance().addToRequestQueue(strReq);
响应总是给空数组和服务器发送消息给我,我的$ _POST [&#34;来自&#34;]依此类推
我将另一个活动的值传递给此活动,这里我是如何得到这个值的...... 首先我声明String:
String textfrom, textto, seat
然后通过意图从另一个活动中获取价值
Intent extras = getIntent();
if (extras.hasExtra("page")) {
String value = extras.getStringExtra("page");
if(value.equals("search")) {
textfrom_btn = extras.getStringExtra("from");
textto_btn = extras.getStringExtra("to");
seat = extras.getStringExtra("seat");
}
}
之后和volley StringRequest代码...