login.jsp;
<body>
<div id="box1">
</div>
<div id="box">
<form action="dologin.jsp" method="post">
<p class="main">
<label>用户名:</label>
<input name="username" value="" >
<label>密码:</label>
<input type="password" name="password" value="">
</p>
<p class="space">
<input type="submit" value="登录" class="login" style="cursor:pointer;">
</p>
</form>
</div>
</body>
login_failure.jsp
<body>
<div id="box">
登录失败,请检查您的用户名或者密码<br>
<a href="login.jsp">返回登录</a>
</div>
</body>
login_success.jsp
<div id="box">
<%
String loginUser="";
if(session.getAttribute("loginUser")!=null){
loginUser=session.getAttribute("loginUser").toString();
}
%>
欢迎<font color="red"><%=loginUser %></font>,登录成功
</div>
dologin.jsp
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String username="";
String password="";
request.setCharacterEncoding("utf-8");
username=request.getParameter("username");
password=request.getParameter("pasword");
if("admin".equals(username) && "admin".equals(password)){
session.setAttribute("loginUser",username);
request.getRequestDispatcher("login_success.jsp").forward(request,response);
}else{
response.sendRedirect("login_failure.jsp");
}
%>
dologin.jsp里面的《password=request.getParameter("pasword");》“pasword”是不是少了一个“s”。