JSP专题

获取提交信息

2018-08-17  本文已影响0人  神坛下的我

index.jsp

<body>
    <form action="result.jsp" name="form" method="get">
        name:<input name="name" type="text" id="name" style="width:120px"><br>
        password:<input name="pwd" type="password" id="pwd" style="width:120px"><br>
        age:<input name="age" type="text" id="age" style="width:120px"><br>
        sex:<input name="sex" type="text" id="sex" style="width:120px"><br>
        email:<input name="email" type="text" id="email" style="width:120px"><br>
        <br>
        <input type="submit" name="Submit" value="Submit"/>
    </form>

</body>

result.jsp

<body>
    <%
        String name= request.getParameter("name");
        String pwd = request.getParameter("pwd");
        String age = request.getParameter("age");
        String sex = request.getParameter("sex");
        String email = request.getParameter("email");
    %>
    <table height="150px" width="300px">
        <tr>
            <td align="center" colspan="4" height="20"></td>
        </tr>
        <tr>
            <td align="center" colspan="4" height="20">GetFormMsg</td>
        </tr>
        <tr>
            <td>Name:</td>
            <td>
                <%if(name==null||"".equals(name)){
                    out.println("");
                }else{
                    out.println(name);
                }%>
            </td>
        </tr>
        <tr>
            <td>Password:</td>
            <td>
                <%if(pwd==null||"".equals(pwd)){
                    out.println("");
                }else{
                    out.println(pwd);
                }%>
            </td>
        </tr>
        <tr>
            <td>Age:</td>
            <td>
                <%if(age==null||"".equals(age)){
                    out.println("");
                }else{
                    out.println(age);
                }%>
            </td>
        </tr>
        <tr>
            <td>Sex:</td>
            <td>
                <%if(sex==null||"".equals(sex)){
                    out.println("");
                }else{
                    out.println(sex);
                }%>
            </td>
        </tr>
        <tr>
            <td>Email:</td>
            <td>
                <%if(email==null||"".equals(email)){
                    out.println("");
                }else{
                    out.println(email);
                }%>
            </td>
        </tr>
    </table>
</body>
7.PNG
上一篇 下一篇

猜你喜欢

热点阅读