<%@ page contentType="text/html;charset=GB2312" %><HTML><Body bgcolor=cyan><Font size=2><h1 align="center">用户登录界面</h1><FORM action="" method="post"><table width="248" border="0" align="center"><tr><td>用户名:</td><td><input type="text" name="useName" ></td></tr><tr><td>密 码:</td><td><input type="password" name="password" ></td></tr><tr><td colspan="2" align="center" valign="middle"><input type="submit" name="button" value="登录"></td></tr></table></FORM></Font><% if(request.getParameter("useName")=="admin")if(request.getParameter("password")=="123456"){response.sendRedirect("index.jsp");}%></Body></HTML>
&& "123456".equals(request.getParameter("password"))) {
response.sendRedirect("index.jsp");
}追问
如果我还要判断如果密码或账号输错了则要在登录页面显示出账号或者密码错误请重新输入,怎么添加代码呢???
追答“账号或者密码错误请重新输入”显示到哪?
追问就是显示到登录按钮下面 ,或者跳出个账号密码错误提示框
追答String u = request.getParameter("useName");String p = request.getParameter("password");
if (u == null || p == null) {
} else if ("admin".equals(u) && "123456".equals(p)) {
response.sendRedirect("index.jsp");
} else {
out.print("<center>账号或者密码错误请重新输入</center>");
//out.print("<script>alert('账号或者密码错误请重新输入')</script>");
}