<%
//页面显示没有问题,就是登录,注册按钮按了没反应
//这是登录页面代码
%>
<%@ 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 XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/denglu.css"/>
<title>登陆</title>
</head>
<body>
<div class="content">
<div id="body">
<img src="Background/1.jpg" />
<div class="denglu">
<div class="top">
<p> User Login </p>
</div>
<form action="doLogin.jsp" method="post">//其实我在想是不是我form标签放的位置错了,但是试了几个位置都不行
<div class="mi">
<img class="tou1" src="images/tou.png" />
<input name="username" id="tou" value="" />
<img class="pa1" src="images/mi.png" />
<input type="password" name="password" id="pa" value=""/>
</div>
<div class="bo">
<input type="button" name="de" id="de" value="登录" />
<input type="button" name="zhu" id="zhu" value="注册" />
</div>
</form>
</div>
</div>
<div id="footer">
<p>@Copyright 2016.3-2016.4 韶关学院丁香苑G103 粤ICP41965262</p>
</div>
</div>
</body>
</html>
<%
//这是doLogin页面代码 ,为了方便测试我直接用的老师的代码应该排除了这部分出错
%>
<%@ 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 username ="";
String password ="";
request.setCharacterEncoding("utf-8");//防止中文乱码
username = request.getParameter("username");
password = request.getParameter("password");
//如果用户和密码都等于admin,则登录成功
if("admin".equals(username)&&"admin".equals(password))
{
session.setAttribute("loginUser", username);
request.getRequestDispatcher("index.jsp").forward(request, response);
}
else
{
response.sendRedirect("LoginFailure.jsp");
}
%>