如何通过截击传递Integer或double值



我想使用getParams方法向服务器发送一个数值。服务器API需要整数值。服务器Api需要整数值,但我发送了一个String值。

我的代码是:

StringRequest request = new StringRequest(Request.Method.GET, C.LOGIN_URL, response, errorListener) {
protected Map<String,String> getParams() {
Map<String, String> map = new HashMap<>();
map.put("NCode", 123456);
map.put("Password", "abc12345");
return map;
}
};
C.addToQueue(request);

我尝试使用String.valueOf,但我的服务器需要一个数值。我的服务器操作系统是windows,语言是asp.net

当我将字符串和int作为正文的一部分发送时,这对我很有效。

JSONObject jsonObject = new JSONObject();
jsonObject.put("NCode", 123456);
jsonObject.put("Password", "abc12345");
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, C.LOGIN_URL, jsonObject, response, errorListener){
//insert code here
};
C.add(request);

最新更新