complex form

来源:互联网 发布:加工中心攻丝编程格式 编辑:程序博客网 时间:2024/05/20 18:42

doPost

    public void doPost(HttpServletRequest request, HttpServletResponse response)            throws ServletException, IOException {        request.setCharacterEncoding("utf-8");        String username = request.getParameter("username");        String password = request.getParameter("password");        String gender = request.getParameter("gender");        String city = request.getParameter("city");        String[] parameterValues = request.getParameterValues("hobbies");        System.out.println(username);        System.out.println(password);        System.out.println(gender);        System.out.println(city);        for (String string : parameterValues) {            System.out.println(string);        }    }

form.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>    <head>        <title>form.html</title>        <meta http-equiv="content-type" content="text/html; charset=UTF-8">    </head>    <body>        <h3>            交友注册        </h3>        <form action="/d_request/reg" method="post">            <table>                <tr>                    <td>                        用户名:                    </td>                    <td>                        <input type="text" name="username" />                    </td>                </tr>                <tr>                    <td>                        密码:                    </td>                    <td>                        <input type="password" name="password" />                    </td>                </tr>                <tr>                    <td>                        确认密码:                    </td>                    <td>                        <input type="password" name="repassword" />                    </td>                </tr>                <tr>                    <td>                        性别:                    </td>                    <td>                        <input type="radio" name="gender" value="male"><input type="radio" name="gender" value="female"></td>                </tr>                <tr>                    <td>                        出生年月:                    </td>                    <td>                        <input type="text" name="birthday" />                    </td>                </tr>                <tr>                    <td>                        爱好:                    </td>                    <td>                        <input type="checkbox" name="hobbies" value="吹气球">                        吹气球                        <input type="checkbox" name="hobbies" value="打篮球">                        打篮球                        <input type="checkbox" name="hobbies" value="打乒乓">                        打乒乓                        <input type="checkbox" name="hobbies" value="洗澡澡">                        洗澡澡                    </td>                </tr>                <tr>                    <td>                        城市:                    </td>                    <td>                        <select name="city">                            <option value="北京">                                北京                            <option value="美国">                                美国                            <option value="东京">                                东京                        </select>                    </td>                </tr>                <tr>                    <td>                        个人介绍                    </td>                    <td>                        <textarea rows="2" cols="50" name="introduction"></textarea>                    </td>                </tr>                <tr>                    <td colspan="2">                        <input type="submit" value="注册" />                    </td>                </tr>            </table>        </form>    </body></html>
0 0
原创粉丝点击