• 课程信息管理系统


        本系统是基于javaBean+jsp+servelt+Mysql制作而成,大致过程是在java类中实现数据库的连接与关闭,并写出数据库增删改查的函数,以备在Servlet中调用,之后是在jsp中制作页面以及实现页面的跳转和数据的输入,在Servlet中获取jsp中输入的值,并作出判断。在这个实验中,页面跳转通过的是链接,<a href="">   </a>,需要注意的地方是,在几个输入的界面,其中有<form name = "form1"  action = "ClassServlet" method = "post">语句,每个输入界面的name="from"其中的名字应该是不一样的。在Servlet中,我运用了java中的对话框来对输入输出结果进行提醒,通过request.getParameter函数来获取页面输入的值。

    (一)通过Navicat在数据库中建立一个表用来储存信息

    (1)新建一个名为sqltestdb的数据库

    (2)在新建的数据库中新建一个名为shangke的表,表的属性为

    (二)java层

    (1)连接数据库类,在com.util包中创建

    DBUtil.java

    package com.util;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class DBUtil {
        public static String db_url = "jdbc:mysql://localhost:3306/sqltestdb";
        public static String db_user = "root";
        public static String db_password = "751208";
    
        public static Connection getConn() {
            Connection conn = null;
            try {
                Class.forName("com.mysql.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();
                }
            }
        }
    }

    其中db_user和db_password分别是数据库的账号和密码,不同的人可能设置的不一样

    (2)javaBean类,在com.bean包中建立

    ClassBean.java

    package com.bean;
    
    public class ClassBean {
        private String classname;
        private String teachname;
        private String site;
        public String getClassname() {
            return classname;
        }
        public void setClassname(String calssname) {
            this.classname = calssname;
        }
        public String getTeachname() {
            return teachname;
        }
        public void setTeachname(String teachname) {
            this.teachname = teachname;
        }
        public String getSite() {
            return site;
        }
        public void setSite(String site) {
            this.site = site;
        }
        public String toString()
        {
            return "classname="+classname+",teachname="+teachname+",site="+site;
        }
    }

    (3)数据库增删改查类,在com.dao中建立

    ClassDao.java

    package com.dao;
    import com.util.DBUtil;
    import com.bean.ClassBean;
    
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    
    import org.apache.tomcat.util.buf.StringUtils;
    
    
    
    public class ClassDao {
        public static int testInsert(String classname,String teachname,String site) throws Exception//增加
        {
            int count = 0;
            Connection conn = DBUtil.getConn();
            try {
                String sql="insert into shangke values(?,?,?)";
                PreparedStatement preparedStatement=conn.prepareStatement(sql);
                preparedStatement.setString(1, classname);
                preparedStatement.setString(2, teachname);
                preparedStatement.setString(3, site);
                count=preparedStatement.executeUpdate();
                conn.close();
            }catch (Exception e) {
                e.printStackTrace();
            }
            return count;
        }
        public static int testUpdate1(String xiugainame,String xiuname) throws Exception//修改
        {
            int count=0;
            Connection conn = DBUtil.getConn();
            try {
                String sql="update shangke set classname=? where classname=?";
                PreparedStatement preparedStatement=conn.prepareStatement(sql);
                preparedStatement.setString(1, xiuname);
                preparedStatement.setString(2, xiugainame);
                count=preparedStatement.executeUpdate();
                System.out.println(count);
                conn.close();
            }catch (Exception e) {
                e.printStackTrace();
            }
            return count;
        }
        public static int testUpdate2(String xiugainame,String xiuteach) throws Exception//修改
        {
            int count=0;
            Connection conn = DBUtil.getConn();
            try {
                String sql="update shangke set teachname=? where classname=?";
                PreparedStatement preparedStatement=conn.prepareStatement(sql);
                preparedStatement.setString(1, xiuteach);
                preparedStatement.setString(2, xiugainame);
                count=preparedStatement.executeUpdate();
                System.out.println(count);
                conn.close();
            }catch (Exception e) {
                e.printStackTrace();
            }
            return count;
        }
        public static int testUpdate3(String xiugainame,String xiusite) throws Exception//修改
        {
            int count=0;
            Connection conn = DBUtil.getConn();
            try {
                String sql="update shangke set site=? where classname=?";
                PreparedStatement preparedStatement=conn.prepareStatement(sql);
                preparedStatement.setString(1, xiusite);
                preparedStatement.setString(2, xiugainame);
                count=preparedStatement.executeUpdate();
                System.out.println(count);
                conn.close();
            }catch (Exception e) {
                e.printStackTrace();
            }
            return count;
        }
        public int testDelete(String shanclass) throws Exception//删除
        {
            int count=0;
            Connection conn = DBUtil.getConn();
            try {
                String sql="delete from shangke where classname=?";
                PreparedStatement preparedStatement=conn.prepareStatement(sql);
                preparedStatement.setString(1, shanclass);
                count=preparedStatement.executeUpdate();
                System.out.println(count);
                conn.close();
            }catch (Exception e) {
                e.printStackTrace();
            }
            return count;
        }
        public static List<ClassBean> select(String name, String teacher, String place) {//查找
            List<ClassBean> beans = new ArrayList<ClassBean>();
            Connection conn = DBUtil.getConn();
            ClassBean adminBean=null;
            try {
                String sql="select * from shangke";
                Statement state = conn.createStatement();
                ResultSet rs = state.executeQuery(sql);
                while(rs.next()) {
                    adminBean = new ClassBean();
                    adminBean.setClassname(rs.getString("classname"));
                    adminBean.setTeachname(rs.getString("teachname"));
                    adminBean.setSite(rs.getString("site"));
                    beans.add(adminBean);
                }
                
            
                conn.close();
            }catch (Exception e) {
                e.printStackTrace();
            }
            List<ClassBean> results = new ArrayList<ClassBean>();
            if(name!="")
            {
                Pattern pattern = Pattern.compile(name);
                for(int i=0;i<beans.size();i++)
                {
                    Matcher matcher = pattern.matcher(((ClassBean)beans.get(i)).getClassname());
                    if(matcher.find()){
                         results.add(beans.get(i));
                       }
                }
            }
            if(teacher!="")
            {
                Pattern pattern = Pattern.compile(teacher);
                for(int i=0;i<beans.size();i++)
                {
                    Matcher matcher = pattern.matcher(((ClassBean)beans.get(i)).getTeachname());
                    if(matcher.find()){
                         results.add(beans.get(i));
                       }
                }
            }
            if(place!="")
            {
                Pattern pattern = Pattern.compile(place);
                for(int i=0;i<beans.size();i++)
                {
                    Matcher matcher = pattern.matcher(((ClassBean)beans.get(i)).getSite());
                    if(matcher.find()){
                         results.add(beans.get(i));
                       }
                }
            }
            return results;
        }
    }

    (4)Servlet类,在com.servlet包中创建

    ClassServlet.java,接受添加页面的信息

    package com.servlet;
    
    import java.io.IOException;
    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 javax.swing.JOptionPane;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import com.bean.ClassBean;
    import com.dao.ClassDao;
    import com.util.DBUtil;
    @WebServlet("/ClassServlet")
    public class ClassServlet extends HttpServlet {
        private static final long serialVersionUID = 1L;
           
        public ClassServlet() {
            super();
        }
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("UTF-8");
            String addclass=request.getParameter("addclass");
            String addteacher=request.getParameter("addteach");
            String addsite=request.getParameter("addsite");
            ClassBean admin=null;
            Connection conn = DBUtil.getConn();
            try {
                    Statement state = conn.createStatement();
                    String sql = "select * from shangke";
                    ResultSet rs = state.executeQuery(sql);
                    while(rs.next()) {
                        admin = new ClassBean();
                        admin.setClassname(rs.getString("classname"));
                        admin.setTeachname(rs.getString("teachname"));
                        admin.setSite(rs.getString("site"));
                        if(admin.getClassname().equals(addclass))
                        {
                            JOptionPane.showMessageDialog(null, "操作错误", "课程名称重复", JOptionPane.ERROR_MESSAGE);
                            request.getRequestDispatcher("add.jsp").forward(request, response);
                            return;
                        }
                    }
                    rs.close();
                conn.close();
        }catch (Exception e) {
            e.printStackTrace();
        }
            if(addteacher.equals("王建民")||addteacher.equals("刘立嘉")||addteacher.equals("刘丹")||addteacher.equals("王辉")||addteacher.equals("杨子光"))
            {
            }
            else
            {
                JOptionPane.showMessageDialog(null, "操作错误", "没有这名教师", JOptionPane.ERROR_MESSAGE);
                request.getRequestDispatcher("add.jsp").forward(request, response);
                return;
            }
            if(addsite.equals("一教")||addsite.equals("二教")||addsite.equals("三教")||addsite.equals("基教"))
            {}
            else
            {
                JOptionPane.showMessageDialog(null, "操作错误", "上课地点错误", JOptionPane.ERROR_MESSAGE);
                request.getRequestDispatcher("add.jsp").forward(request, response);
                return;
            }
            ClassDao admin1=new ClassDao();
            int n = 0;
            try {
                n = admin1.testInsert(addclass,addteacher,addsite);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if(n!=0)
            {
                 int res=JOptionPane.showConfirmDialog(null, "操作成功", "是否继续", JOptionPane.YES_NO_OPTION);
                                 if(res==JOptionPane.YES_OPTION){ 
                                     request.getRequestDispatcher("jiemian.jsp").forward(request, response);   //点击“是”后执行这个代码块
                                }else{
                                      System.out.println("选择否后执行的代码");    //点击“否”后执行这个代码块
                                      return;
                                  } 
            }
            else
            {
                JOptionPane.showMessageDialog(null, "操作错误", "请重新操作", JOptionPane.ERROR_MESSAGE);
                request.getRequestDispatcher("add.jsp").forward(request, response);
            }
        }
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request, response);
        }
    
    }

    DeleteServlet.java,接受删除页面的信息

    package com.servlet;
    
    import java.io.IOException;
    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 javax.swing.JOptionPane;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import com.bean.ClassBean;
    import com.dao.ClassDao;
    import com.util.DBUtil;
    @WebServlet("/DeleteServlet")
    public class DeleteServlet extends HttpServlet {
        private static final long serialVersionUID = 1L;
    
        public DeleteServlet() {
            super();
        }
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("UTF-8");
            String DeleteClass=request.getParameter("Deleteclass");
            ClassBean admin1=null;
            ClassBean admin2=new ClassBean();
            ClassDao admin=new ClassDao();
            Connection conn = DBUtil.getConn();
            try {
                    Statement state = conn.createStatement();
                    String sql = "select * from shangke";
                    ResultSet rs = state.executeQuery(sql);
                    while(rs.next()) {
                        admin1 = new ClassBean();
                        admin1.setClassname(rs.getString("classname"));
                        admin1.setTeachname(rs.getString("teachname"));
                        admin1.setSite(rs.getString("site"));
                        if(admin1.getClassname().equals(DeleteClass))
                        {
                            admin2.setClassname(rs.getString("classname"));
                            admin2.setTeachname(rs.getString("teachname"));
                            admin2.setSite(rs.getString("site"));
                        }
                    }
                    rs.close();
                conn.close();
        }catch (Exception e) {
            e.printStackTrace();
        }
            int i=0;
            int res=JOptionPane.showConfirmDialog(null, "课程名称="+admin2.getClassname()+",任课教师="+admin2.getTeachname()+",上课地点="+admin2.getSite(), "是否删除", JOptionPane.YES_NO_OPTION);
            if(res==JOptionPane.YES_OPTION){ 
                try {
                    i=admin.testDelete(DeleteClass);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if(i!=0)
                {
                     int res1=JOptionPane.showConfirmDialog(null, "操作成功", "是否继续", JOptionPane.YES_NO_OPTION);
                                     if(res1==JOptionPane.YES_OPTION){ 
                                         request.getRequestDispatcher("jiemian.jsp").forward(request, response);   //点击“是”后执行这个代码块
                                    }else{
                                        request.getRequestDispatcher("jieshu.jsp").forward(request, response);    //点击“否”后执行这个代码块
                                          return;
                                      } 
                }
                else
                {
                    JOptionPane.showMessageDialog(null, "操作错误", "请重新操作", JOptionPane.ERROR_MESSAGE);
                    request.getRequestDispatcher("Delete.jsp").forward(request, response);
                }
            }else{
                request.getRequestDispatcher("jiemian.jsp").forward(request, response);  //点击“否”后执行这个代码块
                return;
            }
            
            
        }
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request, response);
        }
    
    }

    AmendServlet.java,接受修改页面的信息

    package com.servlet;
    
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.Statement;
    
    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 javax.swing.JOptionPane;
    
    import com.bean.ClassBean;
    import com.dao.ClassDao;
    import com.util.DBUtil;
    
    
    @WebServlet("/AmendServlet")
    public class AmendServlet extends HttpServlet {
        private static final long serialVersionUID = 1L;
        public AmendServlet() {
            super();
        }
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("UTF-8");
            String Amendclass=request.getParameter("Amendclass");
            String amendclass=request.getParameter("amendclass");
            String amendteacher=request.getParameter("amendteach");
            String amendsite=request.getParameter("amendsite");
            ClassBean admin=null;
            Connection conn = DBUtil.getConn();
            try {
                    Statement state = conn.createStatement();
                    String sql = "select * from shangke";
                    ResultSet rs = state.executeQuery(sql);
                    while(rs.next()) {
                        admin = new ClassBean();
                        admin.setClassname(rs.getString("classname"));
                        admin.setTeachname(rs.getString("teachname"));
                        admin.setSite(rs.getString("site"));
                        if(admin.getClassname().equals(amendclass)&&!amendclass.equals(Amendclass))
                        {
                            JOptionPane.showMessageDialog(null, "操作错误", "课程名称重复", JOptionPane.ERROR_MESSAGE);
                            request.getRequestDispatcher("Amend.jsp").forward(request, response);
                            return;
                        }
                    }
                    rs.close();
                conn.close();
        }catch (Exception e) {
            e.printStackTrace();
        }
            if(amendteacher.equals("王建民")||amendteacher.equals("刘立嘉")||amendteacher.equals("刘丹")||amendteacher.equals("王辉")||amendteacher.equals("杨子光"))
            {
            }
            else
            {
                JOptionPane.showMessageDialog(null, "操作错误", "没有这名教师", JOptionPane.ERROR_MESSAGE);
                request.getRequestDispatcher("Amend.jsp").forward(request, response);
                return;
            }
            if(amendsite.equals("一教")||amendsite.equals("二教")||amendsite.equals("三教")||amendsite.equals("基教"))
            {}
            else
            {
                JOptionPane.showMessageDialog(null, "操作错误", "上课地点错误", JOptionPane.ERROR_MESSAGE);
                request.getRequestDispatcher("Amend.jsp").forward(request, response);
                return;
            }
            ClassDao admin1=new ClassDao();
            int a1=0,a2=0,a3=0;
            try {
            a1=admin1.testUpdate1(Amendclass,amendclass);
            a2=admin1.testUpdate2(Amendclass,amendteacher);
            a3=admin1.testUpdate3(Amendclass,amendsite);
            }catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if(a1!=0&&a2!=0&&a3!=0)
            {
                int res=JOptionPane.showConfirmDialog(null, "操作成功", "是否继续", JOptionPane.YES_NO_OPTION);
                if(res==JOptionPane.YES_OPTION){ 
                    request.getRequestDispatcher("jiemian.jsp").forward(request, response);   //点击“是”后执行这个代码块
               }else{
                     System.out.println("选择否后执行的代码");    //点击“否”后执行这个代码块
                     return;
                 } 
            }
            else
            {
                JOptionPane.showMessageDialog(null, "操作错误", "请重新操作", JOptionPane.ERROR_MESSAGE);
                request.getRequestDispatcher("Amend.jsp").forward(request, response);
            }
        }
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request, response);
        }
    
    }

    (三)jsp层

    jiemian.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
          pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>登录界面</title>
    </head>
    <body>
    <table width = "400" border ="0" height = "300" align = "center" cellpading ="0" style = "font-size:12px;color:#FFFFF;front-weight:bold">
    <Tr height = "50" ><td>&nbsp;</td></Tr>
    <tr>
       <td height = "200"><table width = "98%" border ="0" align = "center" cellpading = "0">
       <form >
      <tr>
       <td>欢迎使用本系统</td>
      </tr>
      <tr>
       <td>请选择功能:</td>
      </tr>
      <tr>
       <td><a href="add.jsp">课程信息录入</a></td>
      </tr>
      <tr>
       <td><a href="Amend.jsp">课程信息修改</a></td>
      </tr>
      <tr>
      <td><a href="Delete.jsp">删除课程信息</a></td>
      </tr>
      <tr>
      <td><a href="Select.jsp">查询课程信息</a></td>
      </tr>
     </form>
     </table>
     </td>
     </tr>
    </table>
    </body>
    </html>

    add.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
          pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>登录界面</title>
    </head>
    <body>
    <table width = "400" border ="0" height = "300" align = "center" cellpading ="0" style = "font-size:12px;color:#FFFFF;front-weight:bold">
    <Tr height = "50" ><td>&nbsp;</td></Tr>
    <tr>
       <td height = "200"><table width = "98%" border ="0" align = "center" cellpading = "0">
       <form name = "form1"  action = "ClassServlet" method = "post">
    <tr>
    <td>课程名称:</td><td><input type="text" name="addclass" /></td>
    </tr>
    <tr>
    <td>任课老师:</td><td><input type="text" name="addteach" /></td>
    </tr>
    <tr>
    <td>上课地点:</td><td><input type="text" name="addsite" /></td>
    </tr>
    <tr>
    <td><input name = "login" type = "submit" id = "login" value = "保存" class = "button"></td>
    </tr>
     </form>
     </table>
     </td>
     </tr>
    </table>
    </html>

    Delete.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
          pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>登录界面</title>
    </head>
    <body>
    <table width = "400" border ="0" height = "300" align = "center" cellpading ="0" style = "font-size:12px;color:#FFFFF;front-weight:bold">
    <Tr height = "50" ><td>&nbsp;</td></Tr>
    <tr>
       <td height = "200"><table width = "98%" border ="0" align = "center" cellpading = "0">
       <form name = "form3"  action = "DeleteServlet" method = "post">
    <tr>
    <td>要删除的课程的名称:</td><td><input type="text" name="Deleteclass" /></td>
    </tr>
    <tr>
    <td><input name = "login" type = "submit" id = "login" value = "保存" class = "button"></td>
    </tr>
     </form>
     </table>
     </td>
     </tr>
    </table>
    </html>

    Amend.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
          pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>登录界面</title>
    </head>
    <body>
    <table width = "400" border ="0" height = "300" align = "center" cellpading ="0" style = "font-size:12px;color:#FFFFF;front-weight:bold">
    <Tr height = "50" ><td>&nbsp;</td></Tr>
    <tr>
       <td height = "200"><table width = "98%" border ="0" align = "center" cellpading = "0">
       <form name = "form2"  action = "AmendServlet" method = "post">
    <tr>
    <td>要修改课程的名称:</td><td><input type="text" name="Amendclass" /></td>
    </tr>
    <tr>
    <td>改后课程名称:</td><td><input type="text" name="amendclass" /></td>
    </tr>
    <tr>
    <td>任课老师:</td><td><input type="text" name="amendteach" /></td>
    </tr>
    <tr>
    <td>上课地点:</td><td><input type="text" name="amendsite" /></td>
    </tr>
    <tr>
    <td><input name = "login" type = "submit" id = "login" value = "保存" class = "button"></td>
    </tr>
     </form>
     </table>
     </td>
     </tr>
    </table>
    </html>

    Select.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
          pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>登录界面</title>
    </head>
    <body>
    <table width = "400" border ="0" height = "300" align = "center" cellpading ="0" style = "font-size:12px;color:#FFFFF;front-weight:bold">
    <Tr height = "50" ><td>&nbsp;</td></Tr>
    <tr>
       <td height = "200"><table width = "98%" border ="0" align = "center" cellpading = "0">
       <form name = "form4"  action = "jieshou.jsp" method = "post">
    <tr>
    <td>课程名称:</td><td><input type="text" name="Selectclass" /></td>
    </tr>
    <tr>
    <td>任课老师:</td><td><input type="text" name="Selectteach" /></td>
    </tr>
    <tr>
    <td>上课地点:</td><td><input type="text" name="Selectsite" /></td>
    </tr>
    <tr>
    <td><input name = "login" type = "submit" id = "login" value = "提交" class = "button"></td>
    </tr>
     </form>
     </table>
     </td>
     </tr>
    </table>
    </html>

    jieshou.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
          pageEncoding="UTF-8"%>
          <%@page import="java.util.List" %>
          <%@page import="com.bean.ClassBean" %>
          <%@page import="com.dao.ClassDao" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>登录界面</title>
    </head>
    <body>
    <table width = "400" border ="0" height = "300" align = "center" cellpading ="0" style = "font-size:12px;color:#FFFFF;front-weight:bold">
    <Tr height = "50" ><td>&nbsp;</td></Tr>
    <tr>
       <td height = "200"><table width = "98%" border ="0" align = "center" cellpading = "0">
       <form >
      <tr>
       <td>欢迎使用本系统</td>
      </tr>
      <tr>
      <%
        request.setCharacterEncoding("UTF-8");
        String Selectclass=request.getParameter("Selectclass");
        String Selectteacher=request.getParameter("Selectteach");
        String Selectsite=request.getParameter("Selectsite");
        ClassBean c=null;
        List<ClassBean> beans = ClassDao.select(Selectclass, Selectteacher, Selectsite);
        for(int i=0;i<beans.size();i++)
        {
            c=beans.get(i);
            out.println("</br>");
            out.println("课程名称="+c.getClassname()+",任课老师="+c.getTeachname()+",上课地点="+c.getSite());
        }
      %>
      </tr>
      <tr>
      <td><a href="jiemian.jsp">返回</a></td>
      </tr>
      <tr>
      <td><a href="jieshu.jsp">结束</a></td>
      </tr>
     </form>
     </table>
     </td>
     </tr>
    </table>
    </body>
    </html>

    jieshu.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
          pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>登录界面</title>
    </head>
    <body>
    <table width = "400" border ="0" height = "300" align = "center" cellpading ="0" style = "font-size:12px;color:#FFFFF;front-weight:bold">
    <Tr height = "50" ><td>&nbsp;</td></Tr>
    <tr>
       <td height = "200"><table width = "98%" border ="0" align = "center" cellpading = "0">
       <form >
      <tr>
       <td>欢迎使用本系统</td>
      </tr>
      <tr>
       <td>欢迎再次使用</td>
      </tr>
     </form>
     </table>
     </td>
     </tr>
    </table>
    </body>
    </html>
  • 相关阅读:
    UVa 11572
    Codeforces Round #500 (Div. 2) C.Photo of The Sky
    C++中的1LL
    Codeforces Round #500 (Div. 2) ABC
    UVA11054 Wine trading in Gergovia
    UVA 11134 Fabled Rooks (贪心)
    uva1152
    牛客网暑期ACM多校训练营(第一场)A Monotonic Matrix(数学公式+思维)
    牛客网暑期ACM多校训练营(第三场)A.PACM Team(多重01背包)
    普通平衡树
  • 原文地址:https://www.cnblogs.com/liujinxin123/p/10079675.html
Copyright © 2020-2023  润新知