為什么只跳轉(zhuǎn)到登錄失敗頁面
<%@ page language="java" import="java.util.*" 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 'login.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>
? ? <div>
? <form action="dologin.jsp" method="post">
? ? ? <label>用戶: </label>
? <input name="username" value=""/>
? ? ? <label>密碼: </label>
? <input type="password" name="password"/>
? <input type="submit" value="登錄"/>
??
? </form>
??
? </div>
? ?
? </body>
</html>
<%@ page language="java" import="java.util.*" charset="utf-8"%>
<%
?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("passward");
?
?
?if("admin".equals("username")&&"admin".equals("passward"))
?{
? ?request.getRequestDispatcher("login_success.jsp").forward(request,response);
?}
?else
?{
? ?response.sendRedirect("login_failure.jsp");
?}
%>
<%@ page language="java" import="java.util.*" 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 '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>
? ? ? 登錄失敗 <br>
? </body>
</html>
<%@ page language="java" import="java.util.*" 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 '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>
? ? ? 登錄成功 <br>
? </body>
</html>
2016-10-23
你的dologin.jsp里面的if語句的password給你寫成passward了。粗心啊