小编C. *_*ant的帖子

无法使用Java发送帖子表单

代码的目标是将参数插入表单然后提交表单,然后将表单数据输入MySQL数据库.问题是该方法不发布数据.我不确定我做错了什么,我已经看了很多这方面的问题,但似乎没什么用.

这是表格.

<form action="http://localhost/Documents/dataadded.php" method="post">

<b>Add a New Data</b>

<p>Email Address:
<input type="text" name="email_address" size="30" value="" />
</p>

<p>Email Pass:
<input type="text" name="email_pass" size="30" value="" />
</p>

<p>
<input type="submit" name="submit" value="Send" />
</p>

</form>
Run Code Online (Sandbox Code Playgroud)

这是Java代码.

public static void main(String[] args) {


    String key1 = "email_address";
    String key2 = "email_pass";
    String key3 = "submit";

    String param1 = "testemail@gmail.com";
    String param2 = "password123";
    String param3 = "Send";
    try {
        URL website = new URL("http://localhost/Documents/added.php");

        Map<String,String> arguments = new LinkedHashMap<>();
        arguments.put(key1, param1); …
Run Code Online (Sandbox Code Playgroud)

java http httpurlconnection

6
推荐指数
1
解决办法
91
查看次数

标签 统计

http ×1

httpurlconnection ×1

java ×1