java表单提交标签_java – 使用html单元提交表单

我想登录

https://pacer.login.uscourts.gov/csologin/login.jsf.我使用html单位提交登录表单.这是我的代码:

public void submittingForm() throws Exception {

final WebClient webClient = new WebClient();

// Get the first page

final HtmlPage page1 = webClient.getPage("https://pacer.login.uscourts.gov/csologin/login.jsf");

// 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("login");

// final HtmlSubmitButton button = form.getButtonByName("login:j_idt184");

final HtmlTextInput textField = form.getInputByName("login:loginName");

final HtmlTextInput textField1 = form.getInputByName("login:password");

// Change the value of the text field

textField.setValueAttribute("XXX");

textField1.setValueAttribute("XXX");

// Now submit the form by clicking the button and get back the second page.

final HtmlPage page2 = form.getButtonByName("login:j_idt184").click();

System.out.println(page2.asText());

webClient.closeAllWindows();

}

但它总是显示同样的错误:

Exception in thread "main" java.lang.IllegalAccessError: class com.gargoylesoftware.htmlunit.javascript.regexp.HtmlUnitRegExpProxy$FixedSubString cannot access its superclass net.sourceforge.htmlunit.corejs.javascript.regexp.SubString

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:791)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)

at java.net.URLClassLoader.access$100(URLClassLoader.java:71)

at java.net.URLClassLoader$1.run(URLClassLoader.java:361)

at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

at java.lang.ClassLoader.loadClass(ClassLoader.java:423)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.makeContext(HtmlUnitContextFactory.java:227)

at net.sourceforge.htmlunit.corejs.javascript.Context.enter(Context.java:439)

at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:535)

at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538)

at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.initialize(JavaScriptEngine.java:157)

at com.gargoylesoftware.htmlunit.WebClient.initialize(WebClient.java:1141)

at com.gargoylesoftware.htmlunit.WebWindowImpl.setEnclosedPage(WebWindowImpl.java:109)

at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:200)

at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:179)

at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:221)

at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:106)

at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:433)

at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:311)

at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:373)

at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:358)

at htmlunit.HtmlUnit.submittingForm(HtmlUnit.java:63)

at htmlunit.HtmlUnit.main(HtmlUnit.java:28)

Java Result: 1

如何克服上述错误并成功登录以上url.i我在我的代码中使用以下jar:

htmlunit2.9jar,公地code.jar等.哪个jar需要避免上面的错误.

请提供你的建议.

谢谢

阿图尔

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值