碰碰车
2017-04-14 23:51
<form action="dologin.jsp" method="post"> <div class="login" > <div style="margin-top:25px;"> <input name="login_name" id="login_name" type="text" placeholder='账号'/> </div> <div style="margin-top:25px;"> <input name="login_password" id="login_password" placeholder='密码'/> </div> <div style="margin-top:25px;"> <!-- <input type="button" value="登录!" onclick="this.form.submit()"> --> <input type="submit" value="登录" class="login" /> </div> </div> </form>
String username =""; String password =""; request.setCharacterEncoding("utf-8");//防止中文乱码 username = request.getParameter("login_name"); password = request.getParameter("login_password"); //如果用户和密码都等于admin,则登录成功 if("admin".equals(username)&&"123".equals(password)) { session.setAttribute("loginUser", username); request.getRequestDispatcher("test.jsp").forward(request, response); } else { response.sendRedirect("error.jsp"); }
没毛病,jsp地址放错了。抱歉w
JAVA遇见HTML——JSP篇
248278 学习 · 3071 问题
相似问题