Note: Advice in this article will only work for JxBrowser 6. See the corresponding article for JxBrowser 7 here.(注意:本文中的建议仅适用于JxBrowser6,JxBrowser7相应文章请点击这里。)
Some proxy servers require authentication. JxBrowser API allows handling proxy server authentication and providing username & password programmatically. The following code demonstrates how to do it: (某些代理服务器需要身份验证。 JxBrowser API允许处理代理服务器身份验证并以编程方式提供用户名和密码。以下代码演示了如何执行此操作:)
browser.getContext().getNetworkService().setNetworkDelegate(new DefaultNetworkDelegate() { @Override public boolean onAuthRequired(AuthRequiredParams params) { if (params.isProxy()) { params.setUsername("proxy-username"); params.setPassword("proxy-password"); return false; } return true; } });