课堂测试,一小时完成?你敢信,反正我老师就这样干的。
系统要求为:
1、学生以学号、密码登录,登录成功后跳转到选课界面,选课界面包括课程名称、教师名称、上课地点等信息,点击选课按钮,显示选课成功。
2、后台增加用户信息表、选课表(学号、课程名称、教师名称、上课地点)
哈哈哈,,经过几天的学习,我难道完不成嘛?必然不能啊,经过非常紧张的敲键盘后,,完成了,而且排名还是比较靠前的哦!
来,上代码!
登录界面如下:
<%@ page language="java" contentType="text/html; charset=UTF-8" 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>Task04-login</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"> </head> <body> <!--传值到"login_action.jsp" 方式是post隐式传递。--> <form action="login_action.jsp" method="post"> <form action="verifyWindow.jsp" method="get"> <!-- 通过正则表达式决定输入的字符 --> 用户名:<input pattern="[a-zA-Z0-9]{6,12}" name="username"><br /> 密码:<input pattern="[a-zA-Z0-9]{6,12}" type="password" name="password"><br /> <input type="submit" value="登录"><br> </form> </form> <% %> </body> </html>
验证账号密码的界面
<%@ page language="java" contentType="text/html; charset=UTF-8" 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>Task04-login_action</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"> </head> <body> <% String username = request.getParameter("username"); //session.setAttribute("username",username); String password = request.getParameter("password"); //session.setAttribute("password",password); %> <!-- 判断字符串是否为空,为空就转到最初的登录页面 --> <% if (username.equals("") && password.equals("")) { response.setHeader("refresh", "3;URL=login.jsp");//这里的3,是你要确定的时间秒 URL是要跳转的地址 %><font color="red" size="5"> 您的登录信息为空<br> 三秒后将跳转到登录页面 <br> 如果没有跳转,请点击 <a href="denglujiemian.jsp">这里</a>!!! <br> </font> <% } else { out.print("用户名:" + username); %><br> <% out.print("密码:" + password); %><br> <% if (username != null) { if (username.equals("20193878") && password.equals("171017")) { out.print("welcome!!!"); response.setHeader("refresh", "0;URL=showWindow.jsp"); } else { response.setHeader("refresh", "3;URL=denglujiemain.jsp"); %><font color="red" size="5"> 您的登录信息有误<br> 三秒后将跳转到登录页面 <br> 如果没有跳转,请点击 <a href="denglujiemian.jsp">这里</a>!!! <br> </font> <% } } } %> </body> </html>
哈哈哈,,今天先就发这两个界面吧,明天将其余的代码完善在发出来。