zoukankan      html  css  js  c++  java
  • servlet HttpServletRequest 类 2 获取请求参数

    如何获取请求参数

    <body>
      <form action="http://localhost:8080/07_servlet/parameterServlet" method="get">
        用户名:<input type="text" name="username"><br/>
        密码:<input type="password" name="password"><br/>
        兴趣爱好:<input type="checkbox" name="hobby" value="cpp">C++
        <input type="checkbox" name="hobby" value="java">Java
        <input type="checkbox" name="hobby" value="js">JavaScript<br/>
        <input type="submit">
      </form>
    </body>
    protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            // 获取请求参数
            String username = req.getParameter("username");
            String password = req.getParameter("password");
            String[] hobby = req.getParameterValues("hobby");
            System.out.println("用户名:" + username);
            System.out.println("密码:" + password);
            System.out.println("兴趣爱好:" + Arrays.asList(hobby));
        }
  • 相关阅读:
    4组Beta冲刺1/5
    4组Beta冲刺总结
    4组Beta冲刺2/5
    4组Beta冲刺4/5
    4组Beta冲刺5/5
    4组Alpha冲刺6/6
    软工实践个人总结
    4组Alpha冲刺6/6
    4组Beta冲刺3/5
    4组Alpha冲刺总结
  • 原文地址:https://www.cnblogs.com/superxuezhazha/p/12585794.html
Copyright © 2011-2022 走看看