我使用jsp进行简单的登录页面
我的问题是getParameter始终为null
这是我的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>
这是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>
<%
}
%>
这两个变量是alaway null
String id = request.getParameter("userid");
String passwd = request.getParameter("userpw");
我能做什么
答案 0 :(得分:0)
检查这两个类是否
<jsp:useBean id = "brd" class = "mainpage.LoginUser" scope="page"/>
<jsp:useBean id = "brddb" class = "mainpage.UserDB" scope="page"/>
您将id和psswd设置为null。
这可能是你获得null的唯一原因。