尝试从字符串URL数组调用时发现数组类型错误

des4xlb0  于 2021-06-30  发布在  Java
关注(0)|答案(1)|浏览(241)

我只是在运行基于字符串url的get请求时遇到了一个问题。
下面的代码确定字符串url,并将每个url放入表行的数组中。

final String URL_CORE = “/test/platform/auth”;
List<String> urls = new ArrayList<>();
rows.forEach(row -> {
    final String clientValue = row.getCell("client");
    final String uriValue = row.getCell("uri");
    final String typeValue = row.getCell("type"));

    urls.add(URL_CORE + "?" + 
        (clientValue.isEmpty ? "" : CLIENT + "=" + clientValue + "&") +
        (uriValue.isEmpty    ? "" : URI    + "=" + uriValue    + "&") +
        (typeValue.isEmpty   ? "" : TYPE   + "=" + typeValue);
});

在foreach中,我有一段代码,我只想运行url字符串的get请求(一次针对每一行)。它给了我一个不稳定的类型,并想知道我做错了什么?

getRequest(queryParamsList[row]);
rkkpypqq

rkkpypqq1#

从名字上看 queryParamsList 是一个列表,而不是数组,因此必须按 list.get(index) 方法。如果你没有索引,你可以通过 list.indexOf(element)

相关问题