简体   繁体   English

JSP登录getParameter返回null

[英]JSP Login getParameter return null

I'm make simple login page use jsp 我让简单的登录页面使用jsp

my problem is getParameter is always null 我的问题是getParameter始终为null

this is my mainpage.jsp code 这是我的mainpage.jsp代码

<form action = "LoginProcess.jsp" method = "post">  
    <table align="center">
    <tr>
    <td><label for="userid">ID : </label></td>
    <td><input type="text" name="userid" id="userid"></td>
    </tr>
    <tr>
    <td><label for="userpw">PW : </label></td>
    <td><input type="password" name="userpw" id="userpw"></td>
    </tr>
    <tr>
    <td colspan="2" align="center">
    <input type="hidden" name="status">
    <input type="button" name="join" class="loingbtn" value="">
    <input type="button" name="find" class="loingbtn" value="">
    <input type="button" name="booking" class="loingbtn" value="">
    <input type="button" name="msg" class="loingbtn" value="">
    <input type="submit" name="login" class="loginbtn" value="">
</form>

This is loginprocess.jsp 这是loginprocess.jsp

<body>
    <jsp:useBean id = "brd" class = "mainpage.LoginUser" scope="page"/>
    <jsp:useBean id = "brddb" class = "mainpage.UserDB" scope="page"/>
    <%          
        String id = request.getParameter("userid");
        String passwd = request.getParameter("userpw");
        if ((brddb.isLogin(id, passwd))) {  
    %>
    <script>
        alert("Success");
    </script>
    <%
        }else{
            %>
            <script>
            alert("Fail");
            self.close();
            </script>
            <%
        }
%>

this two variable is alaway null 这两个变量始终为null

String id = request.getParameter("userid");
String passwd = request.getParameter("userpw");

what can i do 我能做什么

Check whether in these 2 classes 检查是否在这两个类中

    <jsp:useBean id = "brd" class = "mainpage.LoginUser" scope="page"/>
    <jsp:useBean id = "brddb" class = "mainpage.UserDB" scope="page"/>

you are setting id and psswd to null. 您将id和psswd设置为null。

That could be the only reason you are getting null. 那可能是您变得空的唯一原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM