📄 index.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.net.*" %>
<html>
<head>
<title>学生选课系统</title>
</head>
<body background="images/index.JPEG"><center>
<p><font color="#CC0000" size="50">学生选课系统</font>
<hr>
<br>
<br>
<br>
</p>
<form>
<table width="500" >
<tr height="10"><td width="200" align="right">用户:</td>
<td width="300"><input type="text" name="account" height="15" align="absmiddle"></td>
</tr>
<tr height="10"><td width="200" align="right">密码:</td>
<td width="300"><input type="password" name="password" height="15" align="absmiddle"></td>
</tr>
</table>
<table>
<tr height="10"><td width="300"></td><td width="400" align="left"><input type="radio" name="choice" value="s" checked="ok" align="absmiddle">
学生</td>
</tr>
<tr height="10"><td width="300"></td><td width="400" align="left"><input type="radio" name="choice" value="m">
管理员</td>
</tr>
<tr>
<td width="300"></td><td width="400" align="left"><input type="submit" name="submit" value="登陆" size="20" height="20" > <input type="reset" name="取消" value="取消" size="20" height="20">
</td>
</tr>
</table>
</form>
<%
if(request.getParameter("submit")!=null)
{
if(request.getParameter("account") != null && request.getParameter("password") != null)
{
String accountID = request.getParameter("account");
String accountPW = request.getParameter("password");
String sql;
%>
<jsp:useBean id="statement" class="student.Connect" />
<%
try{
Connection con = statement.getCon();
Statement smt = con.createStatement();
String choose = request.getParameter("choice");
if(!choose.equals("s"))
sql = "select * from Administrator where A_ID = '"+accountID+"' and Password = '"+ accountPW+"'";
else
sql = "select * from Student where S_ID = '"+accountID+"' and Password = '"+accountPW+"'";
ResultSet account = smt.executeQuery(sql);
if(account.next())
{
session.setAttribute("id",accountID); //将帐号存入session对象以备在其它界面使用
session.setAttribute("type",choose);
session.setAttribute("CID",null);
session.setAttribute("semester",null);
if(choose.equals("s")) response.sendRedirect("student.jsp");
else response.sendRedirect("Administrator.jsp");
}
else
out.println("<script>alert('用户或密码错误!');</script>");
con.close();
}
catch(SQLException sqle)
{
out.println("SQL Exception :"+sqle);
}
}
}
%>
</center>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -