complex form

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值