我尝试admin.do
在登录应用程序后直接访问 URL (),并且该 URL 是一个受限页面。但是,当我在浏览器上运行场景时,我可以看到页面被重定向到访问被拒绝的页面。但是,当我使用 htmlunit 运行相同的程序时,我看到了以下异常。
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 403 Forbidden for https://localhost:27216/app/admin.do
at com.gargoylesoftware.htmlunit.WebClient.throwFailingHttpStatusCodeExceptionIfNecessary(WebClient.java:536)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:331)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:387)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:372)
知道如何实现这一目标吗?这是我的代码。
HtmlPage resp = null;
WebClient webClient = getWebClient();
HtmlPage page = (HtmlPage) webClient.getPage(url);