下载htmlunit时出现异常
Exceptions in downloading htmlunit
我正在为 Java 下载和使用 htmlunit。我将 2.27 版本(我相信这是最新版本)安装为 jar 文件并展开它。代码中充满了导致编译器异常的行,如下所示。
//Code from the WebClient class
//The switch statement has the error according to the compiler.
public WebResponse loadWebResponse(WebRequest webRequest)
throws IOException
{
String str;
switch ((str = webRequest.getUrl().getProtocol()).hashCode()) {case 3076010: if (str.equals("data")) {} break; case 3143036: if (str.equals("file")) break; case 92611469: if ((goto 107) && (str.equals("about")))
{
return makeWebResponseForAboutUrl(webRequest.getUrl());
return makeWebResponseForFileUrl(webRequest);
return makeWebResponseForDataUrl(webRequest);
}
break; }
return loadWebResponseFromWebConnection(webRequest, 20);
}
还有其他人遇到过这个问题吗?如果有,你是怎么处理的?
(Ps。我很抱歉排了这么长;我想保持它的格式与原始代码中的格式相同)
尝试按照以下步骤操作:
- 转到http://htmlunit.sourceforge.net/
在 哪里可以找到... 下单击 最新版本 下面的 link
- 单击以 结尾的文件 link。bin.zip
下载后,将所有文件解压到一个文件夹中,保持文件夹层次结构。
- 将在
/lib
子文件夹中找到的所有 JAR 文件添加到您的 Java 项目的 CLASSPATH。
- 导入类,像这样:
import com.gargoylesoftware.htmlunit.WebClient;
我正在为 Java 下载和使用 htmlunit。我将 2.27 版本(我相信这是最新版本)安装为 jar 文件并展开它。代码中充满了导致编译器异常的行,如下所示。
//Code from the WebClient class
//The switch statement has the error according to the compiler.
public WebResponse loadWebResponse(WebRequest webRequest)
throws IOException
{
String str;
switch ((str = webRequest.getUrl().getProtocol()).hashCode()) {case 3076010: if (str.equals("data")) {} break; case 3143036: if (str.equals("file")) break; case 92611469: if ((goto 107) && (str.equals("about")))
{
return makeWebResponseForAboutUrl(webRequest.getUrl());
return makeWebResponseForFileUrl(webRequest);
return makeWebResponseForDataUrl(webRequest);
}
break; }
return loadWebResponseFromWebConnection(webRequest, 20);
}
还有其他人遇到过这个问题吗?如果有,你是怎么处理的?
(Ps。我很抱歉排了这么长;我想保持它的格式与原始代码中的格式相同)
尝试按照以下步骤操作:
- 转到http://htmlunit.sourceforge.net/
在 哪里可以找到... 下单击 最新版本 下面的 link
- 单击以 结尾的文件 link。bin.zip
下载后,将所有文件解压到一个文件夹中,保持文件夹层次结构。 - 将在
/lib
子文件夹中找到的所有 JAR 文件添加到您的 Java 项目的 CLASSPATH。 - 导入类,像这样:
import com.gargoylesoftware.htmlunit.WebClient;