测试具体要求:

2.系统要求与功能设计

2.1 页面要求

(1)能够在Tomcat服务器中正确部署,并通过浏览器查看;

(2)网站页面整体风格统一;

(3)首页(登录页)要求实现不同用户登录后,进入的功能页不相同。

(4)教师功能页:有添加课程、修改个人信息、浏览选课学生信息三个模块。

(5)学生功能页:有修改个人信息、浏览课程信息、选课三个功能模块。

(5)管理员功能页:有添加教师信息、添加学生信息两个模块。

2.2功能要求:

(1)添加教师信息:管理员可以添加教师基本信息,教师基本信息包括:教师工号(八位数字组成,例如02000081)、教师姓名、教师性别、教师所在学院、职称(教授、副教授、讲师、助教)组成;

(2)添加学生信息:管理可以添加学生基本信息,学生基本信息包括学号(八位数字组成,例如20180052)、学生姓名、学生性别、所在班级、所属专业组成;

(3)添加课程信息:教师登陆后,可以添加自己任职的课程基本信息,课程基本信息包括:课程编号(六位数字组成,例如050013),课程名称、选课人数、任课教师(任课教师不需录入,那位教师填写课程信息,那位教师就是任课教师);

(4)修改个人信息:教师或学生登陆后可以修改个人信息,但教师工号或学号不能修改,另外教师或学生只能修改自己的信息,无法看到或修改其他学生或教师的基本信息。

(5)浏览课程信息:学生登陆后可以看到所有课程的列表信息,点击课程名称可以查看课程的详细信息,包括已选课人数;点击教师名称可以查看教师的详细信息。

(6)选课:进入选课页面,课程信息列表显示所有选课人数未达到课程设置的选课人数上限,点击课程名称可以看到课程详细信息,点击课程详细信息页面的“选课”按钮,可以实现选课功能。

(7)浏览选课学生信息:教师进入该页面后,可以看到自己设置的课程信息列表,点击课程名称,可以看到,选择该课程的所有学生基本信息列表。

(8)登陆功能:管理员、教师、学生登陆后可以看到不同的功能页面,教师或学生登陆后只能看到自己的相关信息,不同教师、不同学生登陆后无法查看其他人的信息。(要求至少创建两个教师用户、十个学生用户演示选课过程)

3数据库设计:

要求实现课程基本信息表、教师基本信息表、学生基本信息表、选课基本信息表。(提示:选课基本信息包括课程编号、教师编号、学号等基本信息)

4、WEB发布:

要求可以实现在浏览器直接访问系统。

如有错误敬请指正

系统简单解释:

1.创建学生或教师的时候id和初始密码一致

2.在程序中使用cookie 来传递参数(emmm  目前只是简单运用)

3.对于身份的判定是在每一个账号后边加status 状态判定

1 为学生  2为教师 3 为管理员

4.对于选课存储时储存在了学生表的class 中,存储类型为课程编号,用String类型进行拼接,查询时进行模糊查询

5.对于选课的人数限制没有完善。

使用jar 包:

数据库建表如下:

代码实现:

com.Bean 类

 package com.Bean;

 public class classes {
private String name;
private String teacher;
private String pid;
private String number;
private String count; public classes(String name, String teacher, String pid, String number) {
super();
this.name = name;
this.teacher = teacher;
this.pid = pid;
this.number = number;
}
public classes(String name, String teacher, String pid, String number, String count) {
super();
this.name = name;
this.teacher = teacher;
this.pid = pid;
this.number = number;
this.count = count;
}
public String getCount() {
return count;
}
public void setCount(String count) {
this.count = count;
}
public String getName() {
return name;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public void setName(String name) {
this.name = name;
}
public String getTeacher() {
return teacher;
}
public void setTeacher(String teacher) {
this.teacher = teacher;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
} }
 package com.Bean;

 public class premission {

     private String name;
private String pwd; public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
} }
 package com.Bean;

 public class student {
private String id;
private String name;
private String sex;
private String classes;
private String zhuanye;
public String getId() {
return id;
}
public student(String id, String name, String sex, String classes, String zhuanye) {
super();
this.id = id;
this.name = name;
this.sex = sex;
this.classes = classes;
this.zhuanye = zhuanye;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getClasses() {
return classes;
}
public void setClasses(String classes) {
this.classes = classes;
}
public String getZhuanye() {
return zhuanye;
}
public void setZhuanye(String zhuanye) {
this.zhuanye = zhuanye;
} }
 package com.Bean;

 public class teacher {

     private String id;
private String name;
private String sex;
private String xueyuan;
private String zhicheng;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getXueyuan() {
return xueyuan;
}
public void setXueyuan(String xueyuan) {
this.xueyuan = xueyuan;
}
public String getZhicheng() {
return zhicheng;
}
public void setZhicheng(String zhicheng) {
this.zhicheng = zhicheng;
}
public teacher(String id, String name, String sex, String xueyuan, String zhicheng) {
super();
this.id = id;
this.name = name;
this.sex = sex;
this.xueyuan = xueyuan;
this.zhicheng = zhicheng;
} }

com.DBUtil类:基础链接

 package com.DBUtil;
/**
* 测试时主要要导入jar
*/ import java.beans.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException; /**
* 建立数据库连接
* @author cuixingyu
*
*/
public class DBUtil {
// 连接数据库 url路径和用户名 密码
public static String db_url="jdbc:mysql://localhost:3306/db_database01?serverTimezone=UTC&characterEncoding=UTF-8&useSSL=false";
public static String db_user="root";
public static String db_password="101032";
public static Connection getConn() {
Connection conn=null;
try {
// 数据库驱动加载
Class.forName("com.mysql.cj.jdbc.Driver");
try {
//链接数据库
conn=DriverManager.getConnection(db_url, db_user, db_password);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("驱动链接加载成功!");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//返回链接
return conn; } //关闭函数
public static void close(Statement state,Connection conn) {
//只有状态和连接时,先关闭状态
if(state!=null) {
try {
((Connection) state).close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
if(conn!=null) {
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
//关闭函数
public static void close(PreparedStatement state,Connection conn) {
if(state!=null) {
try {
((Connection) state).close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
if(conn!=null) {
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} public static void close(ResultSet rs,Statement state,Connection conn) {
if(rs!=null) {
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(state!=null) {
try {
((Connection) state).close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(conn!=null) {
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} //关闭函数
public static void close(java.sql.Statement state, Connection conn) {
// TODO Auto-generated method stub
if(state!=null)
{
try {
state.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(conn!=null) {
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
//测试主函数 利用Java运行来测试
@SuppressWarnings("static-access")
public static void main(String[] args) throws SQLException {
DBUtil dbu=new DBUtil();
dbu.getConn();
}
}

com.Dao 类

 package com.Dao;

 import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List; import com.Bean.classes;
import com.Bean.student;
import com.Bean.teacher;
import com.DBUtil.DBUtil; public class Dao {
//获取登陆用户的身份信息
public int login(String username, String password) { Connection conn = DBUtil.getConn();
Statement state =null;
ResultSet rs = null;
int flag=0;
String sql = "select * from login where name='"+username+"' and pwd = '"+password+"'";
try {
state = conn.createStatement();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} try {
rs=state.executeQuery(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} try {
while(rs.next()) {
flag=rs.getInt("status");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return flag;
}
//在学生界面添加学生信息 --- 未读题
public void addstudent(String id, String name, String sex, String classes, String zhuanye) throws Exception {
Connection conn = DBUtil.getConn();
Statement state =null;
ResultSet rs = null;
String sql="insert into student(pid,name,sex,classes,zhuanye) values('"+id+"','"+name+"','"+sex+"','"+classes+"','"+zhuanye+"')";
state = conn.createStatement();
state.executeUpdate(sql);
DBUtil.close(state, conn);
}
//遍历所有的课程
public List<classes> searchclasses() { //构建遍历函数
List<classes>list =new ArrayList<>();
//建立数据库链接
Connection conn=DBUtil.getConn();
//sql 语句 查询
String sql="select * from classes";
Statement pstmt = null;
try {
//执行sql语句
pstmt = conn.createStatement();
ResultSet rs=pstmt.executeQuery(sql);
classes use=null;
while(rs.next()) {
//遍历获取的信息
String name=rs.getString("name");
String teacher=rs.getString("teacher");
String id=rs.getString("pid");
String number=rs.getString("number");
String count=rs.getString("count"); use=new classes(name,teacher,id,number,count);
list.add(use);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
DBUtil.close(pstmt, conn);
} return list;
}
//增设新课程
public void addclasses(String name, String teacher, String pid, String number,String count) throws SQLException {
Connection conn = DBUtil.getConn();
Statement state =null;
String sql="insert into classes(name,teacher,pid,number,count) values('"+name+"','"+teacher+"','"+pid+"','"+number+"','"+count+"')";
state = conn.createStatement();
state.executeUpdate(sql);
DBUtil.close(state, conn); }
//遍历学生的信息
public static ArrayList<student> getstudent(String pid) throws Exception{
ArrayList<student>list =new ArrayList<>();
Connection conn=DBUtil.getConn();
Statement pstmt = null;
String sql="select * from student where pid = '"+pid+"'";
pstmt = conn.createStatement();
ResultSet rs=pstmt.executeQuery(sql);
student student=null;
while(rs.next()) {
//遍历获取的信息
String id=rs.getString("pid");
String name=rs.getString("name");
String sex=rs.getString("sex");
String classes=rs.getString("classes");
String zy=rs.getString("zhuanye");
student=new student(id,name,sex,classes,zy);
list.add(student);
System.out.println(id);
System.out.println(name);
System.out.println(sex);
System.out.println(classes);
System.out.println(zy);
}
return list; }
//遍历教师的信息
public static ArrayList<teacher> getteacher(String pid) throws Exception{
ArrayList<teacher>list =new ArrayList<>();
Connection conn=DBUtil.getConn();
Statement pstmt = null;
String sql="select * from teacher where pid = '"+pid+"'";
pstmt = conn.createStatement();
ResultSet rs=pstmt.executeQuery(sql);
teacher teacher=null;
while(rs.next()) {
//遍历获取的信息
String id=rs.getString("pid");
String name=rs.getString("name");
String sex=rs.getString("sex");
String xy=rs.getString("xueyuan");
String zc=rs.getString("zhicheng");
teacher=new teacher(id,name,sex,xy,zc);
list.add(teacher);
System.out.println(id);
System.out.println(name);
System.out.println(sex);
System.out.println(xy);
System.out.println(zc);
}
return list; } //修改学生的个人信息 但是jsp学号不允许修改 在这里当作修改的索引
public void updatestudent(String id, String name, String sex, String classes, String zhuanye) throws Exception {
Connection conn = DBUtil.getConn();
Statement state =null;
String sql="update student set name='"+name+"',sex='"+sex+"',classes='"+classes+"',zhuanye='"+zhuanye+"' where pid='"+id+"' ";
state=conn.createStatement();
state.executeUpdate(sql); DBUtil.close(state, conn);
}
// 修改教师个人信息
public void updateteacher(String id, String name, String sex, String xueyuan, String zhicheng) throws Exception {
Connection conn = DBUtil.getConn();
Statement state =null;
String sql="update teacher set name='"+name+"',sex='"+sex+"',xueyuan='"+xueyuan+"',zhicheng='"+zhicheng+"' where pid='"+id+"' ";
state=conn.createStatement();
state.executeUpdate(sql);
System.out.println("更新");
DBUtil.close(state, conn); } public void addteacher(String id, String name, String sex, String classes, String zhuanye) throws Exception {
Connection conn = DBUtil.getConn();
Statement state =null;
String sql="insert into teacher(pid,name,sex,xueyuan,zhicheng) values('"+id+"','"+name+"','"+sex+"','"+classes+"','"+zhuanye+"')";
state = conn.createStatement();
state.executeUpdate(sql);
DBUtil.close(state, conn); } public void loginteacher(String id) throws Exception {
Connection conn = DBUtil.getConn();
Statement state =null;
String sql="insert into login(name,pwd,status) values('"+id+"','"+id+"','"+2+"')";
state = conn.createStatement();
state.executeUpdate(sql);
DBUtil.close(state, conn); } public void loginstudent(String id) throws Exception {
Connection conn = DBUtil.getConn();
Statement state =null;
String sql="insert into login(name,pwd,status) values('"+id+"','"+id+"','"+1+"')";
state = conn.createStatement();
state.executeUpdate(sql);
DBUtil.close(state, conn); }
//选课
public static void addclass(String name,String studentid,String id) throws Exception {
Connection conn = DBUtil.getConn();
Statement state =null;
//给记录课程的数据库做标记
String sql="select * from classes where name = '"+name+"'";
state = conn.createStatement();
ResultSet rs=state.executeQuery(sql);
int count=0;
String a=null;
//获取已经选取该课程的人数
while(rs.next()) {
a=rs.getString("count");
}
//将人数加一
count=Integer.parseInt(a);
count++;
a=Integer.toString(count);
//更新选课人数
String sql1="update classes set count='"+count+"' where name='"+name+"' ";
state.executeUpdate(sql1);
//获取选课学生的先前选课情况
String sql2="select * from student where pid = '"+studentid+"'";
String kecheng=null;
state = conn.createStatement();
ResultSet rs1=state.executeQuery(sql2); while(rs1.next()) {
kecheng=rs1.getString("class");
}
//添加一个新的编号
kecheng=kecheng+","+id;
//给选课的学生做标记 记录学生的选课信息 在学生的数据库内记录
String sql3="update student set class='"+kecheng+"' where pid='"+studentid+"' ";
state.executeUpdate(sql3);
DBUtil.close(state, conn);
}
//通过姓名查询教师信息 不准确
public static List<teacher> getteachers(String names) throws Exception{
ArrayList<teacher>list =new ArrayList<>();
Connection conn=DBUtil.getConn();
Statement pstmt = null;
String sql="select * from teacher where name = '"+names+"'";
pstmt = conn.createStatement();
ResultSet rs=pstmt.executeQuery(sql);
teacher teacher=null;
while(rs.next()) {
//遍历获取的信息
String id=rs.getString("pid");
String name=rs.getString("name");
String sex=rs.getString("sex");
String xy=rs.getString("xueyuan");
String zc=rs.getString("zhicheng");
teacher=new teacher(id,name,sex,xy,zc);
list.add(teacher);
System.out.println("查看教师信息");
}
return list; }
//查询教师开设的课程
public static List<classes> getclass(String names) throws Exception {
// TODO Auto-generated method stub List<classes> list=new ArrayList<>();
Connection conn = DBUtil.getConn();
Statement state =null;
String sql="select * from classes where teacher like '%"+names+"%'";
state = conn.createStatement();
ResultSet rs=state.executeQuery(sql);
classes cs=null;
while(rs.next()) {
String name=rs.getString("name");
String teacher=rs.getString("teacher");
String id=rs.getString("pid");
String number=rs.getString("number");
String count=rs.getString("count");
cs=new classes(name,teacher,id,number,count);
list.add(cs);
System.out.println("教师查询选课结果");
}
return list;
}
//获取学生信息 通过id查找
public static List<student> getstudents(String id) throws Exception {
List<student> list=new ArrayList<>();
Connection conn = DBUtil.getConn();
Statement state =null;
//模糊查询
String sql="select * from student where class like '%"+id+"%'";
state = conn.createStatement();
ResultSet rs=state.executeQuery(sql);
student s=null;
while(rs.next()) {
String pid=rs.getString("pid");
String name=rs.getString("name");
String sex=rs.getString("sex");
String classes=rs.getString("classes");
String zy=rs.getString("zhuanye");
s=new student(pid,name,sex,classes,zy);
list.add(s);
}
return list;
} }

com.Servlet 类:学生 教师 管理员 登陆

 package com.Servlet;

 import java.io.IOException;
import java.io.UnsupportedEncodingException; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import com.Dao.Dao; /**
* Servlet implementation class adminServlet
*/
@WebServlet("/adminServlet")
public class adminServlet extends HttpServlet {
private static final long serialVersionUID = 1L; protected void service(HttpServletRequest req,HttpServletResponse resp)throws ServletException,IOException
{
req.setCharacterEncoding("UTF-8"); String method = req.getParameter("method");
if(method.equals("addstudent"))
{
try {
addstudent(req,resp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} if(method.equals("addteacher"))
{
try {
addteacher(req,resp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
//添加教师信息
private void addteacher(HttpServletRequest req, HttpServletResponse resp) throws Exception { req.setCharacterEncoding("UTF-8"); String id = req.getParameter("id");
String name = req.getParameter("name");
String sex = req.getParameter("sex");
String classes = req.getParameter("classes");
String zhuanye = req.getParameter("zhicheng"); Dao dao=new Dao();
System.out.println(zhuanye);
dao.addteacher(id,name,sex,classes,zhuanye);
dao.loginteacher(id);
//添加完成重新刷新界面
req.getRequestDispatcher("addteacher.jsp").forward(req, resp);
}
//添加学生信息
private void addstudent(HttpServletRequest req, HttpServletResponse resp) throws Exception {
// TODO Auto-generated method stub req.setCharacterEncoding("UTF-8"); String id = req.getParameter("id");
String name = req.getParameter("name");
String sex = req.getParameter("sex");
String classes = req.getParameter("classes");
String zhuanye = req.getParameter("zhuanye"); Dao dao=new Dao();
dao.addstudent(id,name,sex,classes,zhuanye);
dao.loginstudent(id);
//跳转到新的界面
req.getRequestDispatcher("addstudent.jsp").forward(req, resp);
} }
 package com.Servlet;
/*
* 登陆界面调用的Servlet
*/ import java.io.IOException;
import java.io.UnsupportedEncodingException; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import com.Bean.premission;
import com.Dao.Dao; /**
* Servlet implementation class LoginServlet
*/
@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L; protected void service(HttpServletRequest req,HttpServletResponse resp)throws ServletException,IOException
{
req.setCharacterEncoding("UTF-8"); String method = req.getParameter("method");
if(method.equals("login"))
{
login(req,resp);
}
} private void login(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
try {
req.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String username = req.getParameter("user");
String password = req.getParameter("password");
System.out.println(username);
System.out.println(password);
premission p=new premission();
p.setName(username);
p.setPwd(password);
Dao dao=new Dao();
//获取登陆账号的身份权限信息
int status=dao.login(username,password);
//通过状态来跳转不同界面
if(status==1) {
System.out.println("学生");
//设置cookie 作为边的参数
Cookie cookie=new Cookie("student", username);
cookie.setPath("/");
//设置存活时间
cookie.setMaxAge(60*60*24);
resp.addCookie(cookie);
req.getRequestDispatcher("student.jsp").forward(req, resp);
}else if(status==2) {
System.out.println("老师");
//设置cookie 作为边的参数
Cookie cookie=new Cookie("teacher", username);
cookie.setPath("/");
//设置存活时间
cookie.setMaxAge(60*60*24);
resp.addCookie(cookie);
req.getRequestDispatcher("teacher.jsp").forward(req, resp);
}else if(status==3) {
System.out.println("管理员");
//设置cookie 作为边的参数
req.getRequestDispatcher("admin.jsp").forward(req, resp);
}else if(status==0) {
System.out.println("错误");
req.getRequestDispatcher("error.jsp").forward(req, resp);
} } }
 package com.Servlet;

 import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import com.Bean.classes;
import com.Dao.Dao; /**
* Servlet implementation class StudentServlet
*/
@WebServlet("/StudentServlet")
public class StudentServlet extends HttpServlet {
private static final long serialVersionUID = 1L; protected void service(HttpServletRequest req,HttpServletResponse resp)throws ServletException,IOException
{
req.setCharacterEncoding("UTF-8"); String method = req.getParameter("method");
if(method.equals("add"))
{
try {
add(req,resp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(method.equals("show"))
{
try {
show(req,resp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} if(method.equals("update"))
{
try {
update(req,resp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} if(method.equals("addclasses")) {
try {
addclass(req,resp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
//选课
private void addclass(HttpServletRequest req, HttpServletResponse resp) throws Exception {
req.setCharacterEncoding("UTF-8");
String name=req.getParameter("name");
String studentid=req.getParameter("studentid");
String id=req.getParameter("id");
Dao.addclass(name,studentid,id);
req.getRequestDispatcher("show.jsp").forward(req, resp);
}
// 修改学生信息
private void update(HttpServletRequest req, HttpServletResponse resp) throws Exception { req.setCharacterEncoding("UTF-8");
String id = req.getParameter("id");
String name = req.getParameter("name");
String sex = req.getParameter("sex");
String classes = req.getParameter("classes");
String zhuanye = req.getParameter("zhuanye");
Dao dao=new Dao();
dao.updatestudent(id,name,sex,classes,zhuanye);
req.getRequestDispatcher("update1.jsp").forward(req, resp); }
//展示所有的课程
private void show(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
req.setCharacterEncoding("UTF-8"); Dao dao=new Dao();
List<classes> list= dao.searchclasses();
req.setAttribute("list", list);
req.getRequestDispatcher("show.jsp").forward(req, resp);
}
// 添加学生信息
private void add(HttpServletRequest req, HttpServletResponse resp) throws Exception {
// TODO Auto-generated method stub
try {
req.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String id = req.getParameter("id");
String name = req.getParameter("name");
String sex = req.getParameter("sex");
String classes = req.getParameter("classes");
String zhuanye = req.getParameter("zhuanye"); System.out.println(id);
System.out.println(name);
System.out.println(sex);
System.out.println(classes);
System.out.println(zhuanye);
Dao dao=new Dao(); dao.addstudent(id,name,sex,classes,zhuanye); //req.getRequestDispatcher("student.jsp").forward(req, resp); } }
 package com.Servlet;

 import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.sql.SQLException;
import java.util.List; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import com.Bean.classes;
import com.Bean.student;
import com.Bean.teacher;
import com.Dao.Dao; /**
* Servlet implementation class TeacherServlet
*/
@WebServlet("/TeacherServlet")
public class TeacherServlet extends HttpServlet {
private static final long serialVersionUID = 1L; protected void service(HttpServletRequest req,HttpServletResponse resp)throws ServletException,IOException
{
req.setCharacterEncoding("UTF-8"); String method = req.getParameter("method");
if(method.equals("add"))
{
try {
add(req,resp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(method.equals("update"))
{
try {
update(req,resp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(method.equals("seacrch")) {
try {
search(req,resp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} if(method.equals("searchclass")) {
try {
searchclass(req,resp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(method.equals("checkstudent")) {
try {
checkstudent(req,resp);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
//查询所选课程的学生信息
private void checkstudent(HttpServletRequest req, HttpServletResponse resp) throws Exception {
req.setCharacterEncoding("UTF-8");
String id=req.getParameter("id");
//获取课程编号 据此查找学生 模糊
List<student>list =Dao.getstudents(id);
req.setAttribute("list", list);
req.getRequestDispatcher("showstudentinfo.jsp").forward(req, resp);
}
//教师查询学生选课结果
private void searchclass(HttpServletRequest req, HttpServletResponse resp) throws Exception {
req.setCharacterEncoding("UTF-8");
String name=req.getParameter("name"); List<classes> list=Dao.getclass(name);
req.setAttribute("list", list);
req.getRequestDispatcher("showselectclass.jsp").forward(req, resp);
}
//查询教师信息
private void search(HttpServletRequest req, HttpServletResponse resp) throws Exception {
req.setCharacterEncoding("UTF-8");
String name=req.getParameter("name");
List<teacher> list=Dao.getteachers(name);
req.setAttribute("list", list);
req.getRequestDispatcher("showteacherinfo.jsp").forward(req, resp);
}
//修改教师个人信息
private void update(HttpServletRequest req, HttpServletResponse resp) throws Exception {
req.setCharacterEncoding("UTF-8");
String id = req.getParameter("id");
String name = req.getParameter("name");
String sex = req.getParameter("sex");
String xueyuan = req.getParameter("xueyuan");
String zhicheng = req.getParameter("zhicheng");
Dao dao=new Dao();
dao.updateteacher(id,name,sex,xueyuan,zhicheng);
req.getRequestDispatcher("update2.jsp").forward(req, resp); }
//添加新的课程
private void add(HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException, SQLException {
// TODO Auto-generated method stub
req.setCharacterEncoding("UTF-8"); String name = req.getParameter("name");
String teacher= req.getParameter("teacher");
String pid = req.getParameter("id");
String number = req.getParameter("number");
String count="0";
Dao dao=new Dao();
dao.addclasses(name,teacher,pid,number,count);
}
}

jsp界面:

 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>管理员添加学生</title> </head>
<body> <div class="container">
<section>
<form action="StudentServlet?method=add" method="post" onsubmit="return check()">
<span class="cname">学号</span>
<input type="text" name="id" class="icname" placeholder=" class-name" id="id">
<br/> <span class="teacher">姓名</span>
<input type="text" name="name" class="iteacher" placeholder=" teacher" id="name">
<br/> <span class="place">性别</span>
<label><input type="radio" name="sex" id="sex" value="男">男</label>
<label><input type="radio" name="sex" id="sex" value="女">女</label>
<br/> <span class="place">班级</span>
<input type="text" name="classes" class="iteacher" placeholder=" teacher" id="classes">
<br/> <span class="place">专业</span>
<input type="text" name="zhuanye" class="iteacher" placeholder=" teacher" id="zhuanye">
<br/> <input type="submit" value="保存" class="butn">
<br/>
</form>
</section>
</div> <script type="text/javascript"> </script> </body>
</html>
 <%@page import="com.Dao.*"%>
<%@page import="com.Bean.*"%>
<%@page import="org.apache.jasper.tagplugins.jstl.core.ForEach"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>教师添加新课程</title> </head>
<script type="text/javascript">
function onload()
{
<%
Cookie[] cookies=request.getCookies();
String value="";
ArrayList<teacher> list=new ArrayList<>();
if(cookies!=null){
System.out.println("cookie的长度为:"+cookies.length);
for(int i=0;i<cookies.length;i++)
{ if(cookies[i].getName().equals("teacher"))
{
value=cookies[i].getValue();
System.out.println(value+":");
list=Dao.getteacher(value);
}
}
}
%>
}
</script>
<body> <div class="container">
<section>
<form action="TeacherServlet?method=add" method="post" onsubmit="return check()">
<%for(teacher s:list)
{ %>
<span class="cname">课程名称</span>
<input type="text" name="name" class="icname" placeholder=" class-name" id="name">
<br/> <span class="teacher">课程教师</span>
<input type="text" name="teacher" class="iteacher" readonly="readonly" placeholder=" teacher" id="teacher" value=<%=s.getName() %>>
<br/>
<% } %>
<span class="place">课程人数</span>
<input type="text" name="number" class="iplace" placeholder=" number" id="number">
<br/> <span class="place">课程编号</span>
<input type="text" name="id" class="iplace" placeholder=" class-id" id="id">
<br/> <input type="submit" value="保&nbsp;存" class="butn">
<br/>
</form>
</section>
</div> </body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>管理员添加学生</title> </head>
<body> <div class="container">
<section>
<form action="adminServlet?method=addstudent" method="post" onsubmit="return check()">
<span class="cname">学号</span>
<input type="text" name="id" class="icname" placeholder=" xuehao" id="id">
<br/> <span class="teacher">姓名</span>
<input type="text" name="name" class="iteacher" placeholder=" name" id="name">
<br/> <span class="place">性别</span>
<label><input type="radio" name="sex" id="sex" value="男">男</label>
<label><input type="radio" name="sex" id="sex" value="女">女</label>
<br/> <span class="place">班级</span>
<input type="text" name="classes" class="iteacher" placeholder=" banji" id="classes">
<br/> <span class="place">专业</span>
<input type="text" name="zhuanye" class="iteacher" placeholder=" zhuanye" id="zhuanye">
<br/> <input type="submit" value="保存" class="butn">
<br/>
</form>
</section>
</div> <script type="text/javascript"> </script> </body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>管理员添加教师</title> </head>
<body> <div class="container">
<section>
<form action="adminServlet?method=addteacher" method="post" onsubmit="return check()">
<span class="cname">工号</span>
<input type="text" name="id" class="icname" placeholder=" id" id="id">
<br/> <span class="teacher">姓名</span>
<input type="text" name="name" class="iteacher" placeholder=" name" id="name">
<br/> <span class="place">性别</span>
<label><input type="radio" name="sex" id="sex" value="男">男</label>
<label><input type="radio" name="sex" id="sex" value="女">女</label>
<br/> <span class="place">学院</span>
<input type="text" name="classes" class="iteacher" placeholder=" xueyuan" id="classes">
<br/> <span class="place">职称</span>
<select name="zhicheng" id="zhicheng">
<option value="教授">教授</option>
<option value="副教授">副教授</option>
<option value="讲师">讲师</option>
<option value="助教">助教</option>
</select>
<br/> <input type="submit" value="保存" class="butn">
<br/>
</form>
</section>
</div> <script type="text/javascript"> </script> </body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>课程信息管理系统:管理员界面</title> <style type="text/css"> .headframe{
width:100%;
height:130px;
border:0;
} .leftframe{
float:left;
width:250px;
height:600px;
border:0;
} .mainframe{
float:right;
width:1200px;
height:600px;
border:0;
} </style> </head> <iframe src="head.jsp" class="headframe" scrolling="no"></iframe>
<iframe src="left3.jsp" class="leftframe" scrolling="no"></iframe>
<iframe src="main.jsp" name="mainAction" class="mainframe"></iframe> </html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>错误界面</title>
</head>
<body>
用户不存在或者用户密码错误
</body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>标题头</title>
<style type="text/css"> .headdiv{
background-color:#3F51B5;
width:100%;
height:130px;
} .headdiv P{
font-family:YouYuan;
font-size:20px;
color:#E8EAF6;
position:relative;
left:20px;
top:45px;
} .headdiv a{
font-family:YouYuan;
font-size:20px;
color:#E8EAF6; text-align:right;
} </style> </head>
<body> <div class="headdiv">
<p>课程信息管理 </p> <br>
&emsp;&emsp;<a href="index.jsp" target="_top">退出</a>
</div> </body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html> <%@page import="com.Servlet.*"%>
<%@page import="com.Bean.*"%>
<%@page import="com.DBUtil.*"%>
<%@page import="com.Dao.*"%>
<html>
<head>
<meta charset="UTF-8">
<title>登陆界面</title>
<style type="text/css"> .colorcloth{
background-color:#3399FF;
width:100%;
height:210px;
} .container{
background-color:#FFFFFF;
width:400px;
height:210px;
margin:200px auto;
} .buser{
position:relative;
left:30px;
top:5px;
border-radius:3px;
width:210px;
height:20px;
border:#DCDCDC 1px solid;
} .buser:hover{
box-shadow:0 0 12px #1E90FF;
} .bpassword{
position:relative;
left:45px;
top:20px;
border-radius:3px;
width:210px;
height:20px;
border:#DCDCDC 1px solid;
} .bpassword:hover{
box-shadow:0 0 12px #1E90FF;
} .user{
position:relative;
left:20px;
top:5px;
font-size:14px;
font-family:STHeiti;
font-weight:600;
} .password{
position:relative;
left:35px;
top:20px;
font-size:14px;
font-family:STHeiti;
font-weight:600;
} .butn{
position:relative;
left:77px;
top:55px;
width:215px;
height:25px;
border-radius:3px;
color:white;
background-color:#0066CC;
text-align:center;
text-decoration:none;
border:none;
} .butn:hover{
box-shadow:0 0 10px #0066CC;
} .title{
background-color:#FFFFFF;
width:100%;
} .title p{
font-family:YouYuan;
font-size:90px;
color:#0066CC;
text-align:center;
} </style>
</head>
<body>
<div class="title">
<p>课程信息登录</p>
</div> <div class="colorcloth">
<div class="container">
<section>
<form action="LoginServlet?method=login" method="post"> <span class="user">用户名</span>
<input type="text" name="user" class="buser" placeholder=" Usename">
<br/>
<span class="password">密码</span>
<input type="password" name="password" class="bpassword" placeholder=" Password">
<br/>
<input type="submit" value="登录" class="butn">
<br/>
</form>
</section>
</div>
</div> <script type="text/javascript"> </script> </body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>学生左侧栏</title>
<style type="text/css"> .leftMenu{
background-color:#7986CB;
width:250px;
height:600px;
position:relative;
top:0px;
} .menuParent{
background-color:#BBDEFB;
} </style>
</head>
<body> <div class="leftMenu">
<div class="menu"> <div class="menuParent">
<div class="ListTitlePanel">
<div class="ListTitle">
<strong>课程信息管理</strong>
<div class="leftbgbt"></div>
</div>
</div> <div class="menuList">
<!-- <div><a target="mainAction" href="add1.jsp">添加个人信息</a></div> -->
<div><a target="mainAction" href="update1.jsp">修改个人信息</a></div>
<div><a target="mainAction" href="StudentServlet?method=show">浏览课程信息</a></div>
</div>
</div> </div>
</div> <script type="text/javascript"> </script> </body>
</html>
 <%@page import="com.Dao.*"%>
<%@page import="com.Bean.*"%>
<%@page import="org.apache.jasper.tagplugins.jstl.core.ForEach"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>教师左侧栏</title>
<style type="text/css"> .leftMenu{
background-color:#7986CB;
width:250px;
height:600px;
position:relative;
top:0px;
} .menuParent{
background-color:#BBDEFB;
} </style> </head>
<script type="text/javascript"> function onload()
{
<%
Cookie[] cookies=request.getCookies();
String value="";
ArrayList<teacher> list=new ArrayList<>();
if(cookies!=null){
System.out.println("cookie的长度为:"+cookies.length);
for(int i=0;i<cookies.length;i++)
{ if(cookies[i].getName().equals("teacher"))
{
value=cookies[i].getValue();
System.out.println(value+":");
list=Dao.getteacher(value);
}
}
}
%>
} </script>
<body onload="onload()"> <div class="leftMenu"> <div class="menu"> <div class="menuParent">
<div class="ListTitlePanel">
<div class="ListTitle">
<strong>课程信息管理</strong>
<div class="leftbgbt"></div>
</div>
</div>
<%for(teacher s:list)
{ %>
<div class="menuList">
<div><a target="mainAction" href="add2.jsp">添加课程信息</a></div>
<div><a target="mainAction" href="update2.jsp">修改个人信息</a></div>
<div><a target="mainAction" href="TeacherServlet?method=searchclass&name=<%=s.getName() %>">浏览选课信息</a></div>
</div>
<% } %>
</div> </div>
</div> <script type="text/javascript"> </script> </body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>管理员左侧栏</title>
<style type="text/css"> .leftMenu{
background-color:#7986CB;
width:250px;
height:600px;
position:relative;
top:0px;
} .menuParent{
background-color:#BBDEFB;
} </style>
</head>
<body> <div class="leftMenu">
<div class="menu"> <div class="menuParent">
<div class="ListTitlePanel">
<div class="ListTitle">
<strong>课程信息管理</strong>
<div class="leftbgbt"></div>
</div>
</div> <div class="menuList">
<div><a target="mainAction" href="addstudent.jsp">添加学生</a></div>
<div><a target="mainAction" href="addteacher.jsp">添加教师</a></div>
</div>
</div> </div>
</div> <script type="text/javascript"> </script> </body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>显示界面</title>
</head>
<body> <div align="left">
<font style="background-color: blue">显示界面 </font>
</div>
</body>
</html>
 <%@page import="com.Dao.*"%>
<%@page import="com.Bean.*"%>
<%@page import="org.apache.jasper.tagplugins.jstl.core.ForEach"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>课程浏览</title>
</head>
<script type="text/javascript">
function onload()
{
<%
Cookie[] cookies=request.getCookies();
String value="";
ArrayList<student> list=new ArrayList<>();
if(cookies!=null){
System.out.println("cookie的长度为:"+cookies.length);
for(int i=0;i<cookies.length;i++)
{ if(cookies[i].getName().equals("student"))
{
value=cookies[i].getValue();
System.out.println(value+":");
list=Dao.getstudent(value);
}
}
}
%>
}
</script >
<body onload="onload()">
<div align="center">
<h1>课程信息浏览:</h1> <form action="StudentServlet?method=show" method="post" onsubmit="return check()">
<table>
<tr>
<td>课程名称</td>
<td>任课教师</td>
<td>课程编号</td>
<td>课程人数</td>
<td align="center" colspan="1">操作</td>
</tr>
<c:forEach items="${list}" var="item">
<tr>
<td><a href="showclassinfo.jsp?name=${item.name}&teacher=${item.teacher}&pid=${item.pid}&number=${item.number}&count=${item.count}">${item.name}</a></td>
<td><a href="TeacherServlet?method=seacrch&name=${item.teacher}">${item.teacher}</a></td>
<td>${item.pid}</td>
<td>${item.number}</td>
<%for(student s:list)
{ %>
<td><a href="StudentServlet?method=addclasses&name=${item.name}&studentid=<%=s.getId() %>&id=${item.pid}">选课</a></td>
<% } %>
</tr>
</c:forEach>
</table>
</form>
</div> </body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div align="center"> <h1>课程详细信息查询</h1>
<table border="1">
<tr>
<td>课程名称</td>
<td>任课教师</td>
<td>课程编号</td>
<td>课程人数</td>
<td>选课人数</td>
</tr>
<tr>
<td>${param.name}</td>
<td>${param.teacher}</td>
<td>${param.pid}</td>
<td>${param.number}</td>
<td>${param.count}</td>
</tr>
</table>
</div> </body>
</html>
 <%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div align="center">
<h1>选课结果浏览:</h1> <form action="TeacherServlet?method=searchclass" method="post" onsubmit="return check()">
<table>
<tr>
<td>课程名称</td>
<td>已选课人数</td>
<td>课程总人数</td> </tr>
<c:forEach items="${list}" var="item">
<tr>
<td><a href="showclassinfo.jsp?name=${item.name}&teacher=${item.teacher}&pid=${item.pid}&number=${item.number}&count=${item.count}">${item.name}</a></td>
<td><a href="TeacherServlet?method=checkstudent&id=${item.pid}">${item.count}</a></td>
<td>${item.number}</td> </tr>
</c:forEach>
</table>
</form>
</div> </body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div align="center">
<h1>学生信息浏览</h1>
<form action="TeacherServlet?method=checkstudent" method="post" >
<table border="1">
<tr>
<td>学生姓名</td>
<td>学生专业</td>
</tr> <c:forEach items="${list}" var="item">
<tr>
<td><a href="showstudentinfos.jsp?id=${item.id}&name=${item.name}&sex=${item.sex}&classes=${item.classes}&zhuanye=${item.zhuanye}">${item.name}</a></td>
<td>${item.zhuanye}</td>
</tr>
</c:forEach> </table>
</form>
</div> </body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div align="center"> <h1>学生详细信息</h1>
<table border="1">
<tr>
<td>学生学号</td>
<td>学生姓名</td>
<td>学生性别</td>
<td>学生班级</td>
<td>学生专业</td>
</tr>
<tr>
<td>${param.id}</td>
<td>${param.name}</td>
<td>${param.sex}</td>
<td>${param.classes}</td>
<td>${param.zhuanye}</td>
</tr>
</table>
</div> </body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div align="center">
<h1>教师信息浏览</h1>
<form action="TeacherServlet?method=seacrch" method="post" >
<table border="1">
<tr>
<td>教师工号</td>
<td>教师姓名</td>
<td>教师性别</td>
<td>所在院系</td>
<td>教师职称</td>
</tr> <c:forEach items="${list}" var="item">
<tr>
<td>${item.id}</td>
<td>${item.name}</td>
<td>${item.sex}</td>
<td>${item.xueyuan}</td>
<td>${item.zhicheng}</td>
</tr>
</c:forEach> </table>
</form>
</div> </body>
</html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>课程信息管理系统:学生界面</title> <style type="text/css"> .headframe{
width:100%;
height:130px;
border:0;
} .leftframe{
float:left;
width:250px;
height:600px;
border:0;
} .mainframe{
float:right;
width:1200px;
height:600px;
border:0;
} </style> <script type="text/javascript"> </script> </head>
<body onload="onload()">
</body> <iframe src="head.jsp" class="headframe" scrolling="no"></iframe>
<iframe src="left1.jsp" class="leftframe" scrolling="no"></iframe>
<iframe src="main.jsp" name="mainAction" class="mainframe"></iframe> </html>
 <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>课程信息管理系统:教师界面</title> <style type="text/css"> .headframe{
width:100%;
height:130px;
border:0;
} .leftframe{
float:left;
width:250px;
height:600px;
border:0;
} .mainframe{
float:right;
width:1200px;
height:600px;
border:0;
} </style> </head> <iframe src="head.jsp" class="headframe" scrolling="no"></iframe>
<iframe src="left2.jsp" class="leftframe" scrolling="no"></iframe>
<iframe src="main.jsp" name="mainAction" class="mainframe"></iframe> </html>
 <%@page import="com.Dao.*"%>
<%@page import="com.Bean.*"%>
<%@page import="org.apache.jasper.tagplugins.jstl.core.ForEach"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改学生信息</title> <style type="text/css"> /* .butn{ */
/* display:inline-block; */
/* padding: 8px 35px; */
/* background-color:#32CD32; */
/* color:white; */
/* border:none; */
/* text-align:center; */
/* text-decoration:none; */
/* border-radius:5px; */
/* position:absolute; */
/* left:40px; */
/* top:95px; */
/* } */ </style> </head>
<script type="text/javascript">
function onload()
{
<%
Cookie[] cookies=request.getCookies();
String value="";
ArrayList<student> list=new ArrayList<>();
if(cookies!=null){
System.out.println("cookie的长度为:"+cookies.length);
for(int i=0;i<cookies.length;i++)
{ if(cookies[i].getName().equals("student"))
{
value=cookies[i].getValue();
System.out.println(value+":");
list=Dao.getstudent(value);
}
}
}
%>
}
</script>
<body onload="onload()"> <div class="container">
<section>
<form action="StudentServlet?method=update" method="post" onsubmit="return check()">
<%for(student s:list)
{ %> <span class="cname" style="background-color: red">学号</span>
<input type="text" name="id" class="icname" placeholder=" class-name" id="id" readonly="readonly" value=<%=s.getId()%> >
<br/> <span class="teacher">姓名</span>
<input type="text" name="name" class="iteacher" placeholder=" teacher" id="name" value=<%=s.getName()%> >
<br/> <span class="place">性别</span>
<label><input type="radio" name="sex" id="sex" value="男">男</label>
<label><input type="radio" name="sex" id="sex" value="女">女</label>
<br/> <span class="place">班级</span>
<input type="text" name="classes" class="iteacher" placeholder=" classes" id="classes" value=<%=s.getClasses() %>>
<br/> <span class="place">专业</span>
<input type="text" name="zhuanye" class="iteacher" placeholder=" zhuangye" id="zhuanye" value=<%=s.getZhuanye() %>>
<br/>
<% } %>
<input type="submit" value="保存" class="butn">
<br/>
</form>
</section>
</div> <script type="text/javascript"> </script> </body>
</html>
 <%@page import="com.Dao.*"%>
<%@page import="com.Bean.*"%>
<%@page import="org.apache.jasper.tagplugins.jstl.core.ForEach"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改教师信息</title> <style type="text/css"> /* .butn{ */
/* display:inline-block; */
/* padding: 8px 35px; */
/* background-color:#32CD32; */
/* color:white; */
/* border:none; */
/* text-align:center; */
/* text-decoration:none; */
/* border-radius:5px; */
/* position:absolute; */
/* left:40px; */
/* top:95px; */
/* } */ </style>
<script type="text/javascript">
function onload()
{
<%
Cookie[] cookies=request.getCookies();
String value="";
ArrayList<teacher> list=new ArrayList<>();
if(cookies!=null){
System.out.println("cookie的长度为:"+cookies.length);
for(int i=0;i<cookies.length;i++)
{ if(cookies[i].getName().equals("teacher"))
{
value=cookies[i].getValue();
System.out.println(value+":");
list=Dao.getteacher(value);
}
}
}
%>
}
</script> </head>
<body> <div class="container">
<section>
<form action="TeacherServlet?method=update" method="post" onsubmit="return check()">
<%for(teacher s:list)
{ %>
<span class="cname">工号</span>
<input type="text" name="id" class="icname" placeholder=" class-name" id="id" readonly="readonly" value=<%=s.getId()%>>
<br/> <span class="teacher">姓名</span>
<input type="text" name="name" class="iteacher" placeholder=" teacher" id="name" value=<%=s.getName()%>>
<br/> <span class="place">性别</span>
<label><input type="radio" name="sex" id="sex" value="男">男</label>
<label><input type="radio" name="sex" id="sex" value="女">女</label>
<br/> <span class="place">学院</span>
<input type="text" name="xueyuan" class="iteacher" placeholder=" teacher" id="xueyuan" value=<%=s.getXueyuan()%>>
<br/> <span class="place">职称</span>
<input type="text" name="zhicheng" class="iteacher" placeholder=" teacher" id="zhicheng" value=<%=s.getZhicheng()%>>
<br/>
<% } %>
<input type="submit" value="保存" class="butn">
<br/>
</form>
</section>
</div> <script type="text/javascript"> </script> </body>
</html>

登陆界面:

操作界面:

学生:

老师:

管理员:

学生选课系统(Java语言期末前测试)的更多相关文章

  1. 学生选课系统 c语言

    /********************************* *主题:学生选修课程系统设计 * *设计要求: *1.添加功能:程序能够任意添加课程和学生记录,可提供选择界面供用户选择所需要添加 ...

  2. JAVA | 学生选课系统

    这里使用JAVA语言编写的简易的学生选课系统,展现的都是这个系统核心代码. 其中有不足欢迎批评和指正! 链接数据库的代码 package connection;//连接数据库student impor ...

  3. java web知识点复习,重新编写学生选课系统的先关操作。

    为了复习之前学习的相关的html,javaweb等知识.自己有重新编写了一遍学生选课系统. 下面主要展示登录界面的代码,以及各个大的主页面的相关jsp. <%@ page language=&q ...

  4. 学生选课系统v1.0

    最近两天写了下老师课上留的作业:学生选课系统.感觉自己写的特别麻烦,思路特别不清晰,平常自己总会偷懒,一些太麻烦细节的功能就不去实现了,用简单的功能来替代,直到自己这回写完这个系统(但自己写的比较lo ...

  5. python开发项目:学生选课系统

    程序要求:1.创建北京.上海两所学校(分析:通过学校类实例化两个学校实例) 2.创建Linux.python.go三个课程,Linux\go在北京开,Linux在上海开(创建Linux.python. ...

  6. python基础-10 程序目录结构 学生选课系统面向对象练习

    一 程序目录结构 1 bin文件夹 二进制文件.代码程序  2 conf 配置文件  3 帮助文档  4 头文件库文件等 二 学生选课系统部分代码 未完待续 1 包内的__init__.py文件 在包 ...

  7. 从零开始学Python06作业思路:学生选课系统

    一,作业要求 选课系统: 管理员: 创建老师:姓名.性别.年龄.资产 创建课程:课程名称.上课时间.课时费.关联老师 学生:用户名.密码.性别.年龄.选课列表[].上课记录{课程1:[di,a,]} ...

  8. 简单的学生选课系统——基于Servlet+Ajax

    以前挖的坑,早晚要往里掉.基础太薄弱,要恶补.在此程序前,我还对Servlet没有一个清晰的概念:一周时间写好此程序之后,对Servlet的理解清晰许多. 这周一直在恶补Spring,今天正好完成了S ...

  9. python实现学生选课系统 面向对象的应用:

    一.要求: 选课系统 管理员: 创建老师:姓名.性别.年龄.资产 创建课程:课程名称.上课时间.课时费.关联老师 使用pickle保存在文件 学生: 学生:用户名.密码.性别.年龄.选课列表[].上课 ...

随机推荐

  1. Intellij IDEA中配置TFS

    TFS是微软推出的一款研发过程管理利器,C#阵营的VS里做了默认集成,但是对于Java阵营的Intellij IDEA,需要安装插件并进行相应配置才能使用: 1.打开配置 2.搜索并安装插件 3.配置 ...

  2. 6 应用Nginx之后

    以上的问题,涉及到Varnish

  3. Java 布尔运算

    章节 Java 基础 Java 简介 Java 环境搭建 Java 基本语法 Java 注释 Java 变量 Java 数据类型 Java 字符串 Java 类型转换 Java 运算符 Java 字符 ...

  4. docker-compose(grafana influxdb) + telegraf 快速搭建简单监控

     灵活实现方案:   1:     telegraf 为go 语言写得占用内存小 收集主机各项监控数据 定时写入 时序DB   influxdb ------------------------&qu ...

  5. MongoDB 删除,添加副本集,并修改副本集IP等信息

    MongoDB 删除,添加副本集,并修改副本集IP等信息 添加副本,在登录到主节点下输入 rs.add("ip:port"); 删除副本 rs.remove("ip:po ...

  6. 三十四、在SAP的屏幕选择中,将英文替换成我们想要的文本内容

    一.我们在代码中定义了一个选择屏幕,但是对应的显示界面为英文 界面如下 二.我们选择[转到]-[文本元素] 三.默认的文本内容是问号和三个点 四.我们修改成我们需要的,并激活这个文本,如果不激活会丢失 ...

  7. ServletContext 详解

    ServletContext——它是一个全局的储存信息的空间,服务器开始,其就存在,服务器关闭,其才释放.request,一个用户可有多个:session,一个用户一个:而servletContext ...

  8. JavaScript的函数和对象介绍

    一.JavaScript中的函数 1.函数的概述 JavaScript中的函数是一段可执行代码的合集,在需要执行的时候可以在方法名之后添加一对小括号执行方法.是一段可执行的字符串. 2.函数中隐藏的属 ...

  9. 关于博主 5ab

    博主是 5ab,一个 ZJ 初一大蒟蒻. 以 5ab 及类似名号在各大 OJ 出没. 欢迎来到 5ab 这个超级大蒟蒻的博客!!! My luogu blog 关于 5ab 的码风 大括号换行!!! ...

  10. Linux学习《第三章重定向,管道符和环境变量》