WebClient HTML单元驱动程序无法正常工作



我是使用WebClient HtmlUnitDriver的新手。我正在使用 htmlunit-2.10.jar 在eclipse中的构建路径中的文件,下面是代码。

final WebClient webClient = new WebClient();
webClient.getPage("https://www.google.co.in");

我要低于错误:

****Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/set/ListOrderedSet**

请让我知道如何解决这一问题,答案将受到赞赏。谢谢!

您的WebClient与您的错误无关:

查看您是否在代码中使用ListOrderSet对象。如果这样做,请尝试导入正确的软件包。我的是:

import org.apache.commons.collections.set.ListOrderedSet;

有关ListOrderSet;

的更多信息,请参见此链接。

尝试设置这些选项旅行客户端对象

WebClient client = new WebClient();
try {
  client.getOptions().setUseInsecureSSL(true);
  client.getOptions().setThrowExceptionOnFailingStatusCode(false);
  client.getOptions().setThrowExceptionOnScriptError(false);
  WebRequest requestSettings = new WebRequest(new URL(REST_URL), methodCall);

,请稍微升级到永不版本,因为它可以使用,例如2.13

最新更新