可以将数据发送到网页的简单 Java 表单吗?

发布于 2024-10-14 15:04:24 字数 146 浏览 4 评论 0原文

我几乎不懂java,但我需要为手机制作一个简单的java应用程序来显示表单。提交后数据将被发送到网页。由于我是一名 php 程序员,我更愿意将其发送到 php 文件,然后该文件将使用表单的数据。我只需要几个输入文本区域,有人可以帮助我处理 java 部分吗? 提前致谢。 尼尔

I know virtually no java, but I need to make a simple java application for mobiles that would display a form.On being submitted The data would then be sent to a webpage. As I am a php programmer, I would prefer to have it sent to a php file, which would then use the form's data. I only need a couple of input text areas, would anybody be able to help me with the java part?
Thanks in advance.
Niall

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

她说她爱他 2024-10-21 15:04:24

您没有提到什么平台,但无论您选择什么,您都需要研究HTTP Client< /a> 这是一个

就呈现形式而言,这非常依赖于平台。

You don't mention what platform but no matter what you choose you will need to look into HTTP Client and here is a good example of mimicking a form based submission.

As far as presenting a form, that's very platform dependent.

甜`诱少女 2024-10-21 15:04:24

如果您可以通过 GET 调用 URL 来调用 PHP 文件,那么您应该能够使用以下代码来解决您的问题:

int variable1 = 4;
String variable2 = "My Phone Service";
URL url = null;
try {
    url = new URL("http://myserver.com/service.php?var1=" + variable1 + "&variable2=" + variable2);
    BufferedReader reader = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream()));
    String s = null;
    while((s= reader.readLine())!=null){
        System.out.println(s);
    }
} catch (MalformedURLException e) {
    e.printStackTrace();  
} catch (IOException e) {
            e.printStackTrace();  
}

If you can call your PHP File by calling an URL via GET, than you should be able to solve your problem with the following piece of code:

int variable1 = 4;
String variable2 = "My Phone Service";
URL url = null;
try {
    url = new URL("http://myserver.com/service.php?var1=" + variable1 + "&variable2=" + variable2);
    BufferedReader reader = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream()));
    String s = null;
    while((s= reader.readLine())!=null){
        System.out.println(s);
    }
} catch (MalformedURLException e) {
    e.printStackTrace();  
} catch (IOException e) {
            e.printStackTrace();  
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文