如何使用 3 个参数映射请求数据<> ?Java - Android Studio



我试图在射击String请求中发送3个POST参数,默认值仅使用2个参数。但是我必须在项目上发送3个参数。我该怎么做?

我尝试在Map<>

中添加字符串参数
`@Override
protected Map<String, String, String> getParams() throws AuthFailureError {
  Map<String, String, String> params = new HashMap<>();
  params.put("username", username);
  params.put("password", password);
  params.put("type", type);
  return  params;
}`

错误消息:

错误的类型参数数:3;需要2。

您不使用类型维度来表达存储额外的键值对。这两种类型是指地图中所有键值对的键值类型,无论它包含零,一,两个还是更多键值对。因此,您的代码可以非常简单地固定在下面。

protected Map<String, String> getParams() throws AuthFailureError {
  Map<String, String> params = new HashMap<>();
  params.put("username", username);
  params.put("password", password);
  params.put("type", type);
  return  params;
}```

相关内容

最新更新