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));
        }
  • 相关阅读:
    cin、cout、cerr、clog------c++ Primer Plus
    c++ 用new后delete,而继续输出指针后果 new/new[]/delete/delete[]区别
    c++类
    c++内联 inline
    c++ 委托构造函数
    c++ explicit
    activti表结构
    工作流设计
    问题解决
    grep 命令
  • 原文地址:https://www.cnblogs.com/superxuezhazha/p/12585794.html
Copyright © 2011-2022 走看看