• jsp用户注册简单实例


    要求

    编程实现用户的注册功能

    注册信息包括:用户名、密码、爱好

    页面提示后,显示用户输入的数据

    注册页面reginput.jsp

    <%--
      Created by IntelliJ IDEA.
      User: 长风
      Date: 2019/9/7
      Time: 15:59
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>用户注册</title>
    </head>
    <body>
    
    <form name="form1" method="post" action="reginfo.jsp">
        <table>
            <tr>
                <td>用户名:</td>
                <td><input type="text" name="name"></td>
            </tr>
            <tr>
                <td>密 码:</td>
                <td><input type="password" name="pwd"></td>
            </tr>
            <tr>
                <td>爱好:</td>
                <td><input type="checkbox" name="channel" value="唱歌">唱歌
                    <input type="checkbox" name="channel" value="跳舞">跳舞
                    <input type="checkbox" name="channel" value="足球">足球
                    <input type="checkbox" name="channel" value="羽毛球">羽毛球
                </td>
            </tr>
            <tr>
                <td>
                    <input type="submit" name="Submit" value="提交">
                    <input type="reset" name="Reset" value="取消">
                </td>
            </tr>
        </table>
    </form>
    
    
    </body>
    </html>
    
    
    

    信息读取显示页面reginfo.jsp

    <%--
      Created by IntelliJ IDEA.
      User: 长风
      Date: 2019/9/7
      Time: 16:12
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>注册信息</title>
    
    </head>
    <body>
    <%
        request.setCharacterEncoding("UTF-8");
    //    设置支持中文字符的字符集
        String name = request.getParameter("name");
    //    name=new String(name.getBytes("ISO-8859-1"),"GBK");
        String pwd = request.getParameter("pwd");
        String[] channels = request.getParameterValues("channel");
    
    
    %>
    你输入的注册信息:<br>
    <table>
        <tr>
            <td>用户名:</td>
            <td><%=name%>
            </td>
        </tr>
        <tr>
            <td>密码:</td>
            <td><%=pwd%>
            </td>
        </tr>
        <tr>
            <td>爱好:</td>
            <%
                if (channels != null) {
                    for (int i = 0; i < channels.length; i++) {
            %>
            <td><%=channels[i]%>
            </td>
            <%
                        // out.println(channels[i]);
                    }
                }
            %>
        </tr>
    </table>
    </body>
    </html>
    
    
    

    效果

    在这里插入图片描述

    2
    在这里插入图片描述

  • 相关阅读:
    【oracle ocp知识点一】
    poj 3280 区间dp
    TextView划线 android
    Apple Watch 集成环信SDK
    Android中使用HttpClient实现HTTP通信效果
    js 数组操作大集合
    5.5二叉树的遍历
    oracle学习之路(二)------数组类型/记录类型的使用
    推荐系统个人理解(实践部分)
    openstack之虚拟机创建流程分析
  • 原文地址:https://www.cnblogs.com/jiangyanblog/p/11668733.html
Copyright © 2020-2023  润新知