从Android,模拟器访问glassfish服务器

时间:2013-05-13 06:31:38

标签: android glassfish emulation

我在笔记本电脑上运行了玻璃鱼。如何从真正的Android设备或模拟器中访问它

1 个答案:

答案 0 :(得分:0)

如果您想使用HTTPURLConnection访问它,您只需:

        HttpURLConnection con = (HttpURLConnection) ( new URL(url)).openConnection();
        con.setRequestMethod("POST");
        con.setDoInput(true);
        con.setDoOutput(true);
        con.connect();

请记住,如果使用模拟器,则localhost(127.0.0.1)对应于10.0.2.2。 打开连接后,您可以使用InputStream或Outpustream进行读写。

如果您使用的是真实设备,请确保您的智能手机上可以看到您的glashfish服务器。

相关问题