如何在小程序中设置Http代理 [英] How to set Http Proxy in an applet

查看:131
本文介绍了如何在小程序中设置Http代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我们设置这些属性后的java桌面应用

For a java desktop application after we set these properties

System.setProperty("java.net.useSystemProxies","true");
System.setProperty("http.proxyHost", "1.1.1.1");
System.setProperty("http.proxyPort", "8080");

每个 http 连接都将通过定义的代理完成.

every http connection will be done through the defined proxy.

但是对于小程序这些不起作用.(在小程序查看器中可以,但在浏览器中不可以.)Applet 始终使用在控制面板\java\网络设置\代理设置中定义的这些设置.

But for an applet these does not work.(In an applet viewer it does but in a browser it doesnt.) Applet always uses these settings which are defined in control panel\java\network settings\proxy settings.

如何在小程序中设置代理?(在每个打开的连接中使用代理类对我来说不是解决方案.)

How can i set the proxy in an applet? (Using proxy class in every opening connection is not a solution for me.)

Applet 使用 java 1.6 进行签名和编译

Applet is signed and compiled with java 1.6

推荐答案

我想系统属性方法不起作用的真正原因是当小程序启动时,Java 运行时系统已经读取了属性并设置默认代理选择器.

I imagine that the real reason that the System properties approach doesn't work is that by the time the applet starts, the Java runtime system has already read the properties and set up the default proxy selector.

您是否尝试过使用 ProxySelector?请参阅本文档的第 4) 节.

Have you tried using ProxySelector? Refer to section 4) of this document.

当然,这只有在您的小程序是签名小程序时才可能起作用.

Of course, this is only likely to work when your applet is a signed applet.

这篇关于如何在小程序中设置Http代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆