<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");
}