【发布时间】:2014-08-12 23:41:53
【问题描述】:
我正在使用 Apache 文档中的示例代码,如下所示:
final WebClient webClient = new WebClient();
// Get the first page
final HtmlPage page1 = webClient.getPage("http://some_url");
// Get the form that we are dealing with and within that form,
// find the submit button and the field that we want to change.
final HtmlForm form = page1.getFormByName("myform");
final HtmlSubmitInput button = form.getInputByName("submitbutton");
final HtmlTextInput textField = form.getInputByName("userid");
// Change the value of the text field
textField.setValueAttribute("root");
// Now submit the form by clicking the button and get back the second page.
final HtmlPage page2 = button.click();
webClient.closeAllWindows();
我收到来自 WebClient、HtmlPage、HtmlForm 的错误...基本上,应该从 Apache 导入的所有内容都没有。
我已经按照网络上的一堆指南指导我在 hwo 上将外部 jar 添加到我的构建路径中,据我所知,一切都设置正确。我试过清理项目、重新启动 Eclipse、关闭/打开项目等。似乎没有任何效果。
作为参考,我从这个网站下载了 .JAR:http://hc.apache.org/。
我的导入语句:
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
我的错误信息:
[2014-06-23 12:43:55 - CampusHappenings] Dx 1 错误;中止 [2014-06-23 12:43:55 - CampusHappenings] 转换为 Dalvik 格式失败,出现错误 1
整个堆栈跟踪太长而无法复制,但它与 htmlunit JAR 本身有关,与我的代码无关。它们看起来都像这样:
Dx 警告:忽略匿名内部类的 InnerClasses 属性 (org.apache.xalan.lib.sql.SecuritySupport12$4) 不附带 关联的 EnclosureMethod 属性。这个类可能是由一个 不针对现代 .class 文件格式的编译器。
想法?我很困惑。
【问题讨论】:
-
你是如何将 jar 添加到构建路径的?
-
我想查看您的代码的完整内容。它有助于消除所有简单的“哎呀”修复。
-
就像@FrankieTheKneeMan 所说,我们至少应该看到您的导入语句。这就是你所说的“进口”,对吧? 究竟您看到的错误消息是什么?
-
你能把你的堆栈跟踪吗?
-
达尔维克?这是否意味着您正在为 Android 编写代码?