周围有**的地方会抛出找不到符号方法getValue()错误。
顺便说一下,该代码是检查我的世界帐户名称有效性的程序的一部分;是否可用。
public String connectToMigrate() {
try {
Connection.Response response =
Jsoup.connect("https://account.mojang.com/migrate").execute();
Document doc = response.parse();
Element authToken = doc.select("input[name^=authenticityToken]").get(0);
Map cookies = response.cookies();
Connection connection =
Jsoup.connect("https://account.mojang.com/migrate/check")
.data("authenticityToken", authToken.val())
.data("mcusername", this.username)
.data("password", this.password)
.method(Connection.Method.POST)
.followRedirects(true);
connection.timeout(10000);
for (Object cookie : cookies.entrySet()) {
connection.cookie((String) **cookie.getValue**(), (String) **cookie.getKey**());
}
Connection.Response postResponse = connection.execute();
if (postResponse.body().toLowerCase().contains("invalid username"))
return "error";
if (postResponse.body().toLowerCase().contains("already been migrated"))
return "error";
if (postResponse.body().toLowerCase().contains("locked out"))
return "error";
if (postResponse.body().toLowerCase().contains("bought minecraft"))
return "error";
if (postResponse.body().toLowerCase().contains("too many failed attempts")) {
getNewProxy();
return "try again";
}
if (postResponse.body().toLowerCase().contains("error")) {
return "try again";
}
Map cookies2 = postResponse.cookies();
Connection connection2 =
Jsoup.connect("https://account.mojang.com/migrate/chooseEmail");
for (Object cookie : cookies2.entrySet()) {
connection2.cookie((String) **cookie.getValue()**, (String) **cookie.getKey()**);
}
connection2.timeout(10000);
Connection.Response postResponse2 = connection2.execute();
String s = postResponse2.body().toLowerCase();
s = s.split("i want to use <strong>")[1];
s = s.split("</strong>")[0];
String email = s;
return email; } catch (Exception e) {
}return "try again";
}
最佳答案
cookie
是一个不包含 getValue()
方法的对象。您需要在调用 getValue()
之前将其转换为正确的类型。
关于java - 这段代码有什么问题吗? (java)(错误: cannot find symbol method getValue() ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11510673/