zoukankan      html  css  js  c++  java
  • request传递参数

    当客户请求时,Servlet容器创建SrevletRequest对象(用于封装客户的请求信息),这个对象将被容器作为service()方法的参数之一传递给Srevlet,Servlet可以利用ServletRequest对象获取客户端请求数据。

    <form action="loing.do" method="post">
                    <div>
                        <span>用户名</span>
                        <div>
                            <input type="text" name="name" id="user" />
                        </div>
                        <span>密码</span>
                        <div>
                            <input type="password" name="password" id="pw" />
                        </div>
                    </div>
                        <div class="button">
                            <input type="submit" value=" 登 录" class="submit">
                        </div>
                </form>

    // 取得请求的参数
            String name = request.getParameter("name");
            String password = request.getParameter("password");

    //用request传递参数

    request.setAttribute("msg", "密码错误,请重新输入!");  

    request.setAttribute("msg", "用户" + name + "登录成功");

    <body>
        <c:if test="${not empty    requestScope.msg}"></c:if>
        <h1>${requestScope.msg}</h1>  获取参数。
    </body>

  • 相关阅读:
    paip.解决Invalid byte 2 of 2byte UTF8 sequence.
    poj1157
    poj1258
    poj1160
    poj1113
    poj1159
    !!!GRETA正则表达式模板类库
    【原创】C#与C++的混合编程采用其中的第三种方法
    WinApi.cs
    C#:正则表达式30分钟入门教程
  • 原文地址:https://www.cnblogs.com/TangGe520/p/8617265.html
Copyright © 2011-2022 走看看