我进行这次设计的初衷是想把这个系统放到易班上,所以正常的情况下是应该是两个端口访问的,但是这里我就只用一个index链过去了吗,方便测试。
index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
学生请假管理系统
学生端
教师端
mysql:这里使用的mysql管理工具是 Navicat Premium 12百度网盘链接:https://pan.baidu.com/s/1MMmK_o5LiviNQkxGnG4R4g 提取码:dmdi 强烈推荐,非常好用。
student.jsp
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" import=" java.util.Date"%>
<%@ page language="java" import=" java.text.SimpleDateFormat"%>
<%
Date date=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
System.out.println(sdf.format(date));
String qingjia_time =(String)sdf.format(date);
%>
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page contentType="text/html;charset=gb2312" %>
<% String []columnName=resultBean.getColumnName();
%>
编号
学生学号
班级
姓名
开始时间
结束时间
申请请假时间
请假原因
辅导员审批状态
辅导员审批时间
辅导员回复
<% String [][] record = resultBean.getTableRecord();
for(int i=0;i
<% for(int j=0;j <%= record[i][j] %>
<% }
%>
<% }
%>
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" import=" java.util.Date"%>
<%@ page language="java" import=" java.text.SimpleDateFormat"%>
<%
Date date=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
System.out.println(sdf.format(date));
String class_teacher_sp_time =(String)sdf.format(date);
%>
<% String []columnName=resultBean.getColumnName();
%>
编号
学生学号
班级
姓名
开始时间
结束时间
申请请假时间
请假原因
辅导员审批状态
辅导员审批时间
辅导员回复
<% String [][] record = resultBean.getTableRecord();
for(int i=0;i
<% for(int j=0;j <%= record[i][j] %>
<% }
%>
<% }
%>
web.xml
This is the description of my J2EE component
This is the display name of my J2EE component
Insert_Servlet
myservlet.control.Insert_Servlet
This is the description of my J2EE component
This is the display name of my J2EE component
Delete_Servlet
myservlet.control.Delete_Servlet
This is the description of my J2EE component
This is the display name of my J2EE component
Select_class_Servlet
myservlet.control.Select_class_Servlet
This is the description of my J2EE component
This is the display name of my J2EE component
Select_number_Servlet
myservlet.control.Select_number_Servlet
This is the description of my J2EE component
This is the display name of my J2EE component
Insert_Sp_Servlet
myservlet.control.Insert_Sp_Servlet
Insert_Servlet
/insert_Servlet
Delete_Servlet
/delete_Servlet
Select_class_Servlet
/Select_class_Servlet
Select_number_Servlet
/Select_number_Servlet
Insert_Sp_Servlet
/insert_Sp_Servlet
index.jsp
studentinfo.java
package mybean.data;
public class studentinfo {
String []columnName ; //存放列名
String [][] tableRecord=null; //存放查询到的记录
public studentinfo() {
tableRecord = new String[1][1];
columnName = new String[1];
}
public void setTableRecord(String [][] s){
tableRecord=s;
}
public String [][] getTableRecord(){
return tableRecord;
}
public void setColumnName(String [] s) {
columnName = s;
}
public String [] getColumnName() {
return columnName;
}
}
Delete_Servlet.java
package myservlet.control;
import mybean.data.studentinfo;
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Delete_Servlet extends HttpServlet{
public void init(ServletConfig config) throws ServletException{
super.init(config);
}
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
studentinfo resultBean=null;
try{ resultBean=(studentinfo)request.getAttribute("resultBean");
if(resultBean==null){
resultBean=new studentinfo(); //创建Javabean对象
request.setAttribute("resultBean",resultBean);
}
}
catch(Exception exp){
resultBean=new studentinfo(); //创建Javabean对象
request.setAttribute("resultBean",resultBean);
}
try{ Class.forName("com.mysql.jdbc.Driver");//加载驱动
}
catch(Exception e){}
request.setCharacterEncoding("gb2312");
String dataBase = request.getParameter("dataBase");
String tableName = request.getParameter("tableName");
String stu_number=request.getParameter("stu_number");
String id=request.getParameter("ID");
String stu_name=request.getParameter("stu_name");
String start_time=request.getParameter("start_time");
String end_time=request.getParameter("end_time");
String qingjia_time=request.getParameter("qingjia_time");
String qingjia_yuanyin=request.getParameter("qingjia_yuanyin");
if(id==null||id.length()==0) {
fail(request,response,"添加记录失败,必须给出记录");
return;
}
String condition = "DELETE FROM "+tableName+" where id='"+id+"'";
System.out.println(condition);
Connection con;
Statement sql;
ResultSet rs;
try{
String uri= "jdbc:mysql://localhost/"+dataBase+"?characterEncoding=utf8";
con=DriverManager.getConnection(uri,"root","root1");//建立连接
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
sql.executeUpdate(condition);
// System.out.println("SELECT * FROM "+tableName+" where stu_number='"+stu_number+"'");
rs=sql.executeQuery("SELECT * FROM "+tableName+" where stu_number='"+stu_number+"'");
ResultSetMetaData metaData = rs.getMetaData();
int columnCount = metaData.getColumnCount(); //得到结果集的列数
String []columnName = new String[columnCount];
for(int i=0;i");
out.println(""+backNews+"
") ;
out.println("返回");
out.println("输入记录");
out.println("