我在我的代码中遇到了 IllegalMonitorStateException,我不确定我为什么会收到它以及如何修复它。我当前的代码是并且错误发生在 try 块中:
public static String scrapeWebsite() throws IOException {
final WebClient webClient = new WebClient();
final HtmlPage page = webClient.getPage(s);
final HtmlForm form = page.getForms().get(0);
final HtmlSubmitInput button = form.getInputByValue(">");
final HtmlPage page2 = button.click();
try {
page2.wait(1);
}
catch(InterruptedException e)
{
System.out.println("error");
}
String originalHtml = page2.refresh().getWebResponse().getContentAsString();
return originalHtml;
}
}