為什么我的一直都是進(jìn)入登錄失敗界面
我根據(jù)老師教的寫的代碼 但是不管輸入的帳號密碼是不是admin 都是進(jìn)入登錄失敗的頁面 ?可否幫看看那里錯了
//login.jsp
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
? <head>
? ? <base href="<%=basePath%>">
? ??
? ? <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0"> ? ?
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
? </head>
??
? <body>
? ?<big><strong><a>用戶登錄</a></strong></big><hr>
? ?<form action="dologin.jsp" method="post">
? ?<table>
? ?<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"><input type="submit" value="登錄"/></td>
? ?</tr>
? ?</table>
? ?</form>
? </body>
</html>
//dologin.jsp
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String usename="";
String password="";
request.setCharacterEncoding("utf-8");//防止中文亂碼
usename=request.getParameter("usename");
password=request.getParameter("password");
//如果用戶名和密碼都是admin則登錄成功否則失敗
if("admin".equals(usename)&&"admin".equals(password))
{ ??
? ? ?session.setAttribute("loginuesname",usename );
? ? ?request.getRequestDispatcher("login_success.jsp").forward(request, response);
? ??
? ? ?}
? ? ?else
? ? ?{
? ? ?response.sendRedirect("login_failure.jsp");
? ? ?}
%>
//login_success.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
? <head>
? ? <base href="<%=basePath%>">
? ??
? ? <title>My JSP 'login_success.jsp' starting page</title>
? ??
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0"> ? ?
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
? </head>
??
? <body>
? <%
? ? String loginusename="";
? ? if(session.getAttribute("loginusename")!=null)
? ? {
? ? ? ?loginusename=session.getAttribute("loginusename").toString();
? ? ? ?}
? ?%>
? ?歡迎您<font color="red"><%=loginusename%></font>登錄成功.
? </body>
</html>
//login_failure.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
? <head>
? ? <base href="<%=basePath%>">
? ??
? ? <title>My JSP 'login_failure.jsp' starting page</title>
? ??
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0"> ? ?
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
? </head>
??
? <body>
? ? <strong>登錄失敗,請返回重新登錄!</strong><br>
? ? <strong><a href="login.jsp">返回登錄</a></strong>
? </body>
</html>
2016-12-20
自己不細(xì)心??磮D
2016-12-15
什么錯誤?