2-学生选课(登录界面)

首先是项目的构建

 

 

然后是数据库中表的构建

 

 

 

 

 

 然后首先是Bean中的对象类

 

kecheng.java

package bean;

public class kecheng {
private String ID;
private String name;
private String renshu;
private String jiaoshi;
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 getRenshu() {
    return renshu;
}
public void setRenshu(String renshu) {
    this.renshu = renshu;
}
public String getJiaoshi() {
    return jiaoshi;
}
public void setJiaoshi(String jiaoshi) {
    this.jiaoshi = jiaoshi;
}
public kecheng(String ID,String name,String renshu,String jiaoshi)
{
    this.ID = ID;
    this.name = name;
    this.renshu = renshu;
    this.jiaoshi = jiaoshi;
}
}

 

student.java

package bean;

public class student {
    private String ID;
    private String name;
    private String sex;
    private String banji;
    private String zhuanye;
    public String getID() {
        return ID;
    }
    public void setID(String iD) {
        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 getBanji() {
        return banji;
    }
    public void setBanji(String banji) {
        this.banji = banji;
    }
    public String getZhuanye() {
        return zhuanye;
    }
    public void setZhuanye(String zhuanye) {
        this.zhuanye = zhuanye;
    }
    
}

 

teacher.java

package 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) {
    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;
}

}

 

yonghu.java(用户的对象类)

package bean;

public class yonghu {
private String number;
private String password;
private String user;
public String getNumber() {
    return number;
}
public void setNumber(String number) {
    this.number = number;
}
public String getPassword() {
    return password;
}
public void setPassword(String password) {
    this.password = password;
}
public String getUser() {
    return user;
}
public void setUser(String user) {
    this.user = user;
}
}

 

dao类

dao.java(进行对数据库的操作)

package dao;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import java.sql.ResultSet;
import java.sql.Statement;
import dbutil.DBUtil;
import bean.kecheng;
import bean.yonghu;
public class dao {
    public int addstudent(String ID,String name,String sex,String banji,String zhuanye)
    {
        Connection conn = DBUtil.getConn();//这里就是从DBUtil类里面得到连接
        Statement state =null;
        ResultSet rs = null;
        int flag=0;
        try
        {
            String sql = "insert into student(ID,name,sex,banji,zhuanye)values('"+ID+"','"+name+"','"+sex+"','"+banji+"','"+zhuanye+"')";
            state = conn.createStatement();
            int count = state.executeUpdate(sql);
            if(count>0) {
                System.out.println("数据插入成功");
            }else {
                System.out.println("数据插入失败了QAQ");
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        finally
        {
            DBUtil.close(rs, state, conn);
        }
        return flag;
    }
    public int addteacher(String ID,String name,String sex,String xueyuan,String zhicheng)
    {
        Connection conn = DBUtil.getConn();//这里就是从DBUtil类里面得到连接
        Statement state =null;
        ResultSet rs = null;
        int flag=0;
        try
        {
            String sql = "insert into teacher(ID,name,sex,xueyuan,zhicheng)values('"+ID+"','"+name+"','"+sex+"','"+xueyuan+"','"+zhicheng+"')";
            state = conn.createStatement();
            int count = state.executeUpdate(sql);
            if(count>0) {
                System.out.println("数据插入成功");
            }else {
                System.out.println("数据插入失败了QAQ");
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        finally
        {
            DBUtil.close(rs, state, conn);
        }
        return flag;
    }
    public int addkecheng(String ID,String name,String renshu,String jiaoshi)
    {
        Connection conn = DBUtil.getConn();//这里就是从DBUtil类里面得到连接
        Statement state =null;
        ResultSet rs = null;
        int flag=0;
        try
        {
            String sql = "insert into kecheng(ID,name,renshu,jiaoshi)values('"+ID+"','"+name+"','"+renshu+"','"+jiaoshi+"')";
            state = conn.createStatement();
            int count = state.executeUpdate(sql);
            if(count>0) {
                System.out.println("数据插入成功");
            }else {
                System.out.println("数据插入失败了QAQ");
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        finally
        {
            DBUtil.close(rs, state, conn);
        }
        return flag;
    }
    public int updatateacher(String ID,String name,String sex,String xueyuan,String zhicheng)
    {
        Connection conn = DBUtil.getConn();//这里就是从DBUtil类里面得到连接
        Statement state =null;
        ResultSet rs = null;
        int flag=0;
        try
        {
            String sql = "update teacher set name='"+name+"',sex='"+sex+"',xueyuan='"+xueyuan+"',zhicheng='"+zhicheng+"' where ID='"+ID+"' ";
            state = conn.createStatement();
            int count = state.executeUpdate(sql);
            if(count>0) {
                System.out.println("数据改变成功");
            }else {
                System.out.println("数据插入失败了QAQ");
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        finally
        {
            DBUtil.close(rs, state, conn);
        }
        return flag;
    }
    public int updatastudent(String ID,String name,String sex,String banji,String zhuanye)
    {
        Connection conn = DBUtil.getConn();//这里就是从DBUtil类里面得到连接
        Statement state =null;
        ResultSet rs = null;
        int flag=0;
        try
        {
            String sql = "update student set name='"+name+"',sex='"+sex+"',banji='"+banji+"',zhuanye='"+zhuanye+"' where ID='"+ID+"' ";
            state = conn.createStatement();
            int count = state.executeUpdate(sql);
            if(count>0) {
                System.out.println("数据改变成功");
            }else {
                System.out.println("数据改变失败了QAQ");
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        finally
        {
            DBUtil.close(rs, state, conn);
        }
        return flag;
    }
    public static List<kecheng> selectkecheng()
    { 
        String sql = "select * from kecheng";
        Connection conn = DBUtil.getConn();//这里就是从DBUtil类里面得到连接
        Statement state =null;
        List<kecheng> list = new ArrayList<>();
        ResultSet rs = null;
        int flag=0;
        try
        {
           
            state = conn.createStatement();
            rs=state.executeQuery(sql);
            kecheng kc=null;
            while(rs.next())
            {
                
                String ID=rs.getString("ID");
                //System.out.println(rs.getString("ID")+"=========");
                String name=rs.getString("name");
                String renshu=rs.getString("renshu");
                String jiaoshi=rs.getString("jiaoshi");
                kc =new kecheng(ID,name,renshu,jiaoshi);
                //System.out.println(name+"=========");
                list.add(kc);
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        finally
        {
            DBUtil.close(rs, state, conn);
        }
        return list;
    }
    public String login(String number,String password,String user)
    {
        Connection conn = DBUtil.getConn();//这里就是从DBUtil类里面得到连接
        Statement state =null;
        ResultSet rs = null;
        int flag=0;
        String user2="";
        try
        {
            String sql = "select * from yonghu ";
            state = conn.createStatement();
            rs=state.executeQuery(sql);
            while(rs.next())
            {
                String number1=rs.getString("number");
                String password1=rs.getString("password");
                String user1=rs.getString("user");
//                if(number1.equals(number)&&password1.equals(password)&&user1.equals(user))
//                {
//                    user2=user1;
//                    System.out.println(user1);
//                }
                if(number1.equals(number)) flag++;
                if(password1.equals(password)) flag++;
                if(user1.equals(user)) flag++;
                if(flag==3) {user2=user;System.out.println(user);}
                flag=0;
            }
//            if(flag==1) user2="账号或密码输入错误";
            if(flag==0) user2="账号或密码输入错误";

        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        finally
        {
            DBUtil.close(rs, state, conn);
        }
        return user2;
    }
    public int adduser(String number,String password,String user)
    {
        Connection conn = DBUtil.getConn();//这里就是从DBUtil类里面得到连接
        Statement state =null;
        ResultSet rs = null;
        int flag=0;
        try
        {
            String sql = "insert into yonghu(number,password,user)values('"+number+"','"+password+"','"+user+"')";
            state = conn.createStatement();
            int count = state.executeUpdate(sql);
            if(count>0) {
                System.out.println("数据插入成功");
            }else {
                System.out.println("数据插入失败了QAQ");
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        finally
        {
            DBUtil.close(rs, state, conn);
        }
        return flag;
    }
}

 

dbutil类

DBUtil.java

package dbutil;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBUtil {//这个类就是套模板如果需要用的时候只需要改数据库(db)的名字即可*******
    //public static String db_url="jdbc:mysql://localhost:3306/database?uerUnicode=true&characterEncoding=UTF-8";
    public static String db_url="jdbc:mysql://localhost:3306/database?serverTimezone=GMT%2B8&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8";//db是数据库的名字
    //这是连接数据库,servlet是数据库的名称,uerUnicode=true&characterEncoding=UTF-8是将字符集设置为utf-8,避免乱码。
    public static String db_user="root";//数据的用户名
    public static String db_password="UJuqCT-az5(f";//数据库的密码
    public static Connection getConn()//获取连接,返回Connection类型,必须设置为static这样才能在其他类中使用
    {
        Connection conn=null;
        try
        {
            Class.forName("com.mysql.cj.jdbc.Driver");//加载驱动
            conn=DriverManager.getConnection(db_url,db_user,db_password);//连接数据库
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        return conn;
    }
    public static void close(Statement state,Connection conn)//关闭函数
    {
        if(state!=null)//只有状态和连接时,先关闭状态
        {
            try
            {
                state.close();
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }
        }
        if(conn!=null)
        {
            try
            {
                conn.close();
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }
        }
    }
    public static void close(ResultSet rs,Statement state,Connection conn)
    {
        if(rs!=null)//有结果集,状态和连接时,先关闭结果集,在关闭状态,在关闭连接
        {
            try
            {
                rs.close();
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }
        }
        if(state!=null)

        {
            try
            {
                state.close();
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }
        }
        if(conn!=null)
        {
            try
            {
                conn.close();
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }
        }
    }
}

 

servlet类

Servlet.java

package servlet;
import java.io.IOException;
import java.util.List;
import java.io.PrintWriter;
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 dao.*;
import bean.kecheng;
import dao.*;
@WebServlet("/r2")
public class Servlet extends HttpServlet{
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
        return;
    }
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");// 设置字符集,避免乱码
        // 获取jsp界面需要进行的操作,
        String method = req.getParameter("method");
        //System.out.println("============");
        if (method.equals("yonghu"))// 转到login函数
        {
            login(req,resp);
           // System.out.println("正在执行信息录入操作");
        }
        if (method.equals("addstudent"))// 转到login函数
        {
            addstudent(req, resp);
           // System.out.println("正在执行信息录入操作");
        }
        if(method.equals("addteacher"))
        {
            addteacher(req,resp);
        }
        if(method.equals("addkecheng"))
        {
            addkecheng(req,resp);
        }
        if(method.equals("updatateacher"))
        {
            updatateacher(req,resp);
        }
        if (method.equals("updatastudent"))// 转到login函数
        {
            updatastudent(req, resp);
           // System.out.println("正在执行信息录入操作");
        }
       if(method.equals("selectkecheng"))
        {
            //System.out.println("select============");
           selectkecheng(req, resp);
        }
       if(method.equals("addUser"))
       {
           //System.out.println("select============");
           addUser(req, resp);
       }
       if(method.equals("login"))
       {
       //    System.out.println("select============");
           login(req, resp);
       }
    }

    private void addstudent(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        String ID=req.getParameter("ID");
        String name = req.getParameter("name");
        String sex=req.getParameter("sex");
        String banji=req.getParameter("banji");
        String zhuanye=req.getParameter("zhuanye");
        
        //System.out.println(name);

        dao  userdao = new dao();
        userdao.addstudent(ID,name,sex,banji,zhuanye);
    }
    private void addteacher(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=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");
        
        //System.out.println(name);

        dao  userdao = new dao();
        userdao.addteacher(ID,name,sex,xueyuan,zhicheng);
    }
    private void addkecheng(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        String ID=req.getParameter("ID");
        String name = req.getParameter("name");
        String renshu=req.getParameter("renshu");
        String jiaoshi=req.getParameter("jiaoshi");
        
        //System.out.println(name);

        dao  userdao = new dao();
        userdao.addkecheng(ID,name,renshu,jiaoshi);
    }
    private void updatateacher(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=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");
        
        //System.out.println(name);

        dao  userdao = new dao();
        userdao.updatateacher(ID,name,sex,xueyuan,zhicheng);
    }
    private void updatastudent(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        String ID=req.getParameter("ID");
        String name = req.getParameter("name");
        String sex=req.getParameter("sex");
        String banji=req.getParameter("banji");
        String zhuanye=req.getParameter("zhuanye");
        
        //System.out.println(name);

        dao  userdao = new dao();
        userdao.updatastudent(ID,name,sex,banji,zhuanye);
    }
    private void selectkecheng(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        List<kecheng> kc=dao.selectkecheng();
        req.setAttribute("kc", kc);
        req.getRequestDispatcher("kechengliulan.jsp").forward(req, resp);
    }
    private void login(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        //System.out.println(name);
        String number=req.getParameter("number");
        String password=req.getParameter("password");
        String user=req.getParameter("user");
       // System.out.println("select============");
        dao  userdao = new dao();
       // 
        String log=userdao.login(number,password,user);
        if(log.equals("管理员"))
        {
            req.getRequestDispatcher("/index.jsp").forward(req,resp);
            System.out.println("select============");
        }
        else if(log.equals("教师"))
        {
            req.getRequestDispatcher("/teacher.jsp").forward(req,resp);
        }
        else if(log.equals("学生"))
        {
            req.getRequestDispatcher("/student.jsp").forward(req,resp);
        }
        else req.getRequestDispatcher("/login.jsp").forward(req,resp);
        
    }
    private void addUser(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        String number=req.getParameter("number");
        String password = req.getParameter("password");
        String user=req.getParameter("user");
        
        //System.out.println(name);

        dao  userdao = new dao();
        userdao.adduser(number,password,user);
    }
}

 

接下来是对于界面代码

 

Creat.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>
<!-- <form action="/Test1/r2?method=addstudent"method="post" onsubmit="return check();"> -->
<form action="/Test1/r2?method=addstudent"method="post">
    姓名<input type="text" name="name"/>
    <input type ="submit" value="提交">
</form>
<script>
function check(){
    alert("ok");
}
</script>
</body>
</html>

 

dengluxuanze.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style> 
body{text-align:center} 
</style>
</head>
<body>
            <p>请如实按照你的真实身份选择</p>
            <a href="http://localhost:8080/Test1/index.jsp">
            <button>管理员</button>
            </a>
            <br/>
            <br/>
            <a href="http://localhost:8080/Test1/jiaoshidenglu.jsp">
            <button>教师</button>
            </a>
            <br/>
            <br/>
            <a href="http://localhost:8080/Test1/studentdenglu.jsp">
            <button>学生</button>
            </a>
</body>
</html>

 

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style> 
body{text-align:center} 
</style>
</head>
<body>
            <p>请选择添加学生信息还是老师信息</p>
            <a href="http://localhost:8080/Test1/student.jsp">
            <button>学生</button>
            </a>
            <br/>
            <br/>
            <a href="http://localhost:8080/Test1/teacher.jsp">
            <button>教师</button>
            </a>
</body>
</html>

 

jiaoshidenglu.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style> 
body{text-align:center} 
</style>
</head>
<body>
            <p>请选择你要实现的功能</p>
            <a href="http://localhost:8080/Test1/kechengtianjia.jsp">
            <button>课程信息录入</button>
            </a>
            <br/>
            <br/>
            <a href="http://localhost:8080/Test1/updatateacher.jsp">
            <button>修改个人信息</button>
            </a>
            <br/>
            <br/>
            <a href="">
            <button>浏览学生信息</button>
            </a>
</body>
</html>

 

kechengliulan.jsp

<%@page import="java.util.*"%>
<%@page import="bean.*"%>
<%@page import="dao.*"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style> 
body{text-align:center} 
</style>
</head>
<body>
<div align="center">
        <h1 style="color: black;">课程详细信息</h1>
        <table class="tb" border="">
        <tr>
            <tr>
                <th>课程编号</th>
                <th>课程名称</th>
                <th>课程选课人数</th>
                <th>任课教师</th> 
            </tr>
            <%List<kecheng> list=(List<kecheng>)request.getAttribute("kc");
            //String s="sd";
            //request.getSession().setAttribute("ss",s);
                for(kecheng kc : list){
             %>
             <tr>
                <td><%=kc.getID() %></td>
                <td><%=kc.getName() %></td>
                <td><%=kc.getRenshu() %></td>
                <td><%=kc.getJiaoshi() %></td>
              </tr>
             
             <%      
                }
            %>
                
        </table>
        <!--  
                <input type="hidden" name="ID" id="ID" value="${kc[0]}">
           
           <td><input type="hidden" name="name" id="name" value="${kc[1]}"></td>
         <tr>
           <td><input type="hidden" name="renshu" id="renshu" value="${kc[2]}"></td>
           </tr>
           <td><input type="hidden" name="jiaoshi" id="jiaoshi" value="${kc[4]}"></td>
           -->
</body>
</html>

 

kechengtianjia.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style> 
body{text-align:center} 
</style>
</head>
<body>
<form action="/Test1/r2?method=addkecheng"method="post">
                    <h1>请输入课程信息</h1>
                    1.课程编号       <input type="text" name="ID"> <br/>
                    2.课程姓名       <input type="text" name="name"> <br/>
                    3.选择此课程的人数<input type="text" name="renshu"> <br/>
                    4.教师姓名       <input type="text" name="jiaoshi"> <br/>
                    <input type ="submit" value="提交">

</form>
</body>
</html>

 

login.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style> 
body{text-align:center} 
input{
    font-size: 20px;
    text-align: center;
}
</style>
</head>
<body>
<form action="/Test1/r2?method=login"method="post" onsubmit="return check();">
 <div id="登录界面">  
        <h1>Login</h1>  
            <table align="center">
                <tr>
                    <th>用户名</th>
                    <td>
                    <input type="text" name="number">
                    </td>
                </tr>
                <tr>
                    <th>密码</th>
                    <td><input type="password" name = "password">
                    </td>
                </tr>        
                    <tr>
                    
                    <th>身份</th><td> <select name="user">
                    <option value="教师">教师</option>
                        <option value="学生">学生</option>
                     <option value="管理员">管理员</option>
                    </select>    
                    </td>
                    </tr>
                <tr>
            <td colspan="2"><input type="submit" name="submit" value="提交"> <input type="reset" value="重置"></td>
                </tr>
            </table>
        </form>
        <div><a href="User.jsp">创建用户</a> <a href="User.html"></a></div>  
    </div>
</body>
</html>

 

student.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style> 
body{text-align:center} 
</style>
</head>
<body>
<form action="/Test1/r2?method=addstudent"method="post" onsubmit="return check();">
                    <h1>请输入学生信息</h1>
                    1.学号<input type="text" name="ID"> <br/>
                    2.姓名<input type="text" name="name"> <br/>
                    3.性别<input type="text" name="sex"> <br/>
                    4.班级<input type="text" name="banji"> <br/>
                    5.专业<input type="text" name="zhuanye"> <br/>
                    <input type ="submit" value="提交">

</form>
</body>
</html>

 

studentdenglu.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style> 
body{text-align:center} 
</style>
</head>
<body>
            <p>请选择你要实现的功能</p>
            <a href="http://localhost:8080/Test1/updatastudent.jsp">
            <button>修改个人信息</button>
            </a>
            <br/>
            <br/>
            <form action="/Test1/r2?method=selectkecheng" method="post" onsubmit="return check();">
                <p>
                    <input type="submit" value="浏览课程信息">
                </p>
            </form>
            <br/>
            <br/>
</body>
</html>

 

teacher.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style> 
body{text-align:center} 
</style>
</head>
<body>
<form action="/Test1/r2?method=addteacher"method="post" onsubmit="return check();">
                    <h1>请输入教师信息</h1>
                    1.学号<input type="text" name="ID"> <br/>
                    2.姓名<input type="text" name="name"> <br/>
                    3.性别<input type="text" name="sex"> <br/>
                    4.学院<input type="text" name="xueyuan"> <br/>
                    5.职称<input type="text" name="zhicheng"> <br/>
                    <input type ="submit" value="提交">

</form>
</body>
</html>

 

updatestudent.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style> 
body{text-align:center} 
</style>
</head>
<body>
<form action="/Test1/r2?method=updatastudent"method="post" onsubmit="return check();">
                    <h1>请输入修改之后的学生信息,注意学号不能改变</h1>
                    1.学号<input type="text" name="ID"> <br/>
                    2.姓名<input type="text" name="name"> <br/>
                    3.性别<input type="text" name="sex"> <br/>
                    4.班级<input type="text" name="banji"> <br/>
                    5.专业<input type="text" name="zhuanye"> <br/>
                    <input type ="submit" value="提交">

</form>
</body>
</html>

 

updateteacher.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style> 
body{text-align:center} 
</style>
</head>
<body>
<form action="/Test1/r2?method=updatateacher"method="post" onsubmit="return check();">
                    <h1>请输入修改之后的教师信息,注意职工号不能改变</h1>
                    1.职工号<input type="text" name="ID"> <br/>
                    2.姓名<input type="text" name="name"> <br/>
                    3.性别<input type="text" name="sex"> <br/>
                    4.学院<input type="text" name="xueyuan"> <br/>
                    5.职称<input type="text" name="zhicheng"> <br/>
                    <input type ="submit" value="提交">

</form>
</body>
</html>

 

User.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="/Test1/r2?method=addUser"method="post" onsubmit="return check();">
                    <h1>请输入信息</h1>
                    1.账号<input type="text" name="number"> <br/>
                    2.密码<input type="text" name="password"> <br/>
                    3.用户  <select name="user">
                    <option value="教师">教师</option>
                        <option value="学生">学生</option>
                     <option value="管理员">管理员</option>
                    </select>    
                    <input type ="submit" value="提交" >

</form>
</body>
</html>
posted @ 2021-12-27 19:05  李迎辉  阅读(178)  评论(0)    收藏  举报