zoukankan      html  css  js  c++  java
  • forward请求转发,param参数传递以及request.getParameter图文讲解

     1 <%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
     2 <!doctype html>
     3 <html>
     4     <head>
     5         <title>login</title>
     6         <meta http-equiv="content-type" comtent="text/html;charset=utf-8"/>
     7     </head>
     8     <body>
     9         <h1><font color="red">欢迎</font></h1>
    10         <form action="loginCheck.jsp" method="get">
    11             <table>
    12                 <tr>
    13                     <td>用户名:</td>
    14                     <td><input type="text" name="name" value=
    15                     "<%=request.getParameter("name")%>" /></td>
    16                 </tr>
    17                 <tr>
    18                     <td>密码:</td>
    19                     <td><input type="password" name="password"/></td>
    20                 </tr>
    21                 <tr>
    22                     <td><input type="submit" value="登录"/></td>
    23                 </tr>
    24             </table>
    25         </form>
    26     </body>
    27 </html>
    View Code
    <%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
    <!doctype html>
    <html>
        <head>
        <title>loginCheck</title>
        <meta http-equiv="content-type" content="text/html;charset=utf-8">
        </head>
        <body>
            <%
                String name = request.getParameter("name");
                String pass = request.getParameter("password");
            %>
            <%
                //if(name.equals("QQ") && password.equals("123"))
                if("QQ".equals(name) && "123".equals(pass))
            {
            %>
            <%--forward作用是转发客户端的请求 --%>
                    <jsp:forward page="success.jsp">
                    <jsp:param name="user" value="<%=name %>"/>
                    </jsp:forward>
            <% }
                else 
                %>
                <%{
                %>    <jsp:forward page="login.jsp">
                    <jsp:param name="name" value="<%=name %>"/>
                    </jsp:forward>
                <%}
                %>
                
        </body>
    </html>
     1 <%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
     2 <!doctype>
     3 <html>
     4     <head>
     5         <title>success</title>
     6         <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
     7     </head>
     8     <body>
     9         <h2>登录成功</h2>
    10         <hr/>
    11         欢迎<%=request.getParameter("user")%>
    12     </body>
    13 </html>

  • 相关阅读:
    DNS解析原理图
    Linux 用户管理
    linux 磁盘基础知识学习
    python中readline判断文件读取结束的方法
    PLSQL Developer连接远程Oracle
    在Linux环境下的卸载Oracle11G操作
    MySQL INSERT插入条件判断:如果不存在则插入
    LoadRunner---杂问题&接口测试
    LoadRunner--获取请求的返回结果函数
    LoadRunner监控Linux条件和解决方法
  • 原文地址:https://www.cnblogs.com/yang--yang/p/4185872.html
Copyright © 2011-2022 走看看