热爱之心略略略
2021-05-24 18:23
采纳率: 66.7%
浏览 129
已采纳

为什么post请求获取不到参数而get请求却可以

post请求

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style type="text/css">
    table{
      margin: auto;
    }
    td{
      border: 1px solid darkturquoise;
    }
  </style>
</head>
<body>
<form method="post" action="UserLoginServlet">
  <table>
    <tr>
      <td>
        <label for="userName">账号</label>
        <input type="text" id="userName" name="userName">
      </td>
    </tr>
    <tr>
      <td>
        <label for="password">密码</label>
        <input type="password" id="password" name="password">
      </td>
    </tr>
    <tr>
      <td>
        <input type="submit" value="登录">
        <input type="reset">
      </td>
    </tr>
  </table>
</form>
</body>
</html>

登录:

查看:

 get请求:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style type="text/css">
    table{
      margin: auto;
    }
    td{
      border: 1px solid darkturquoise;
    }
  </style>
</head>
<body>
<form method="get" action="UserLoginServlet">
  <table>
    <tr>
      <td>
        <label for="userName">账号</label>
        <input type="text" id="userName" name="userName">
      </td>
    </tr>
    <tr>
      <td>
        <label for="password">密码</label>
        <input type="password" id="password" name="password">
      </td>
    </tr>
    <tr>
      <td>
        <input type="submit" value="登录">
        <input type="reset">
      </td>
    </tr>
  </table>
</form>
</body>
</html>

登录:

查看:

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题