相关推荐recommended
JAVAWEB学生信息管理系统保姆级教程(增删改查+登录注册+Filter+mysql)eclipse版
作者:mmseoamin日期:2023-12-25

布局界面:

JAVAWEB学生信息管理系统保姆级教程(增删改查+登录注册+Filter+mysql)eclipse版,第1张

 JAVAWEB学生信息管理系统保姆级教程(增删改查+登录注册+Filter+mysql)eclipse版,第2张

 

Login.css 

@charset "UTF-8";
html{   
    width: 100%;   
    height: 100%;   
    overflow: hidden;   
    font-style: sans-serif;   
}   
body{   
    width: 100%;   
    height: 100%;   
    font-family: 'Open Sans',sans-serif;   
    margin: 0;   
    background-color: #808069;   
}   
#login{   
    position: absolute;   
    top: 50%;   
    left:50%;   
    margin: -150px 0 0 -150px;   
    width: 300px;   
    height: 300px;   
}   
#login h1{   
    color: #fff;   
    text-shadow:0 0 10px;   
    letter-spacing: 1px;   
    text-align: center;   
}   
h1{   
    font-size: 2em;   
    margin: 0.67em 0;   
}   
input{   
    width: 278px;   
    height: 18px;   
    margin-bottom: 10px;   
    outline: none;   
    padding: 10px;   
    font-size: 13px;   
    color: #fff;   
    text-shadow:1px 1px 1px;   
    border-top: 1px solid #312E3D;   
    border-left: 1px solid #312E3D;   
    border-right: 1px solid #312E3D;   
    border-bottom: 1px solid #56536A;   
    border-radius: 4px;   
    background-color: #2D2D3F;   
}   
.but{   
    width: 300px;   
    min-height: 20px;   
    display: block;   
    background-color: #4a77d4;   
    border: 1px solid #3762bc;   
    color: #fff;   
    padding: 9px 14px;   
    font-size: 15px;   
    line-height: normal;   
    border-radius: 5px;   
    margin: 0;   
}

Register.css

@charset "UTF-8";
html{   
    width: 100%;   
    height: 100%;   
    overflow: hidden;   
    font-style: sans-serif;   
}   
body{   
    width: 100%;   
    height: 100%;   
    font-family: 'Open Sans',sans-serif;   
    margin: 0;   
    background-color: #808A87;   
}   
#login{   
    position: absolute;   
    top: 50%;   
    left:50%;   
    margin: -150px 0 0 -150px;   
    width: 300px;   
    height: 300px;   
}   
#login h1{   
    color: #fff;   
    text-shadow:0 0 10px;   
    letter-spacing: 1px;   
    text-align: center;   
}   
h1{   
    font-size: 2em;   
    margin: 0.67em 0;   
}   
input{   
    width: 278px;   
    height: 18px;   
    margin-bottom: 10px;   
    outline: none;   
    padding: 10px;   
    font-size: 13px;   
    color: #fff;   
    text-shadow:1px 1px 1px;   
    border-top: 1px solid #312E3D;   
    border-left: 1px solid #312E3D;   
    border-right: 1px solid #312E3D;   
    border-bottom: 1px solid #56536A;   
    border-radius: 4px;   
    background-color: #2D2D3F;   
}   
.but{   
    width: 300px;   
    min-height: 20px;   
    display: block;   
    background-color: #4a77d4;   
    border: 1px solid #3762bc;   
    color: #fff;   
    padding: 9px 14px;   
    font-size: 15px;   
    line-height: normal;   
    border-radius: 5px;   
    margin: 0;   
}

login.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




登陆界面
 


	  
        

学生信息管理系统


register.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>




注册界面



	  
        

注册


index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="com.bean.StudentBean" %>
    <%@ page import="java.util.*" %>




增删改查界面



	
		
			

学生信息管理系统

你好!欢迎${username} 退出
<% ArrayList stuMessage = (ArrayList) session.getAttribute("stuMessage"); session.removeAttribute("stuMessage"); if(stuMessage != null){ for(int i = 0;i < stuMessage.size();i++){ StudentBean a = (StudentBean)stuMessage.get(i); %> <% } } %>
学号 姓名 班级 年龄 专业
<%=a.getSid() %> <%=a.getSname() %> <%=a.getScls() %> <%=a.getAge() %> <%=a.getMajor() %>


<% String state = (String) session.getAttribute("B2"); session.removeAttribute("B2"); if(state != null){ out.print(state); } %>


<% state = (String) session.getAttribute("B1"); session.removeAttribute("B1"); if(state != null){ out.print(state); } %>

StudentBean.java

package com.bean;
public class StudentBean {
	
	private String sid;
	private String sname;
	private String scls;
	private String age;
	private String major;
	public String getSid() {
		return sid;
	}
	public void setSid(String sid) {
		this.sid = sid;
	}
	public String getSname() {
		return sname;
	}
	public void setSname(String sname) {
		this.sname = sname;
	}
	public String getScls() {
		return scls;
	}
	public void setScls(String scls) {
		this.scls = scls;
	}
	public String getAge() {
		return age;
	}
	public void setAge(String age) {
		this.age = age;
	}
	public String getMajor() {
		return major;
	}
	public void setMajor(String major) {
		this.major = major;
	}
}

AdminDao.java

package com.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.util.DBUtil;
public class AdminDao {
	
	//注册
	public static boolean register(String admin,String password) {
		Connection conn = DBUtil.getConnectDb();
		String sql = "insert into auser (admin,password) values(?,?)";
		int a = 0;
		PreparedStatement stm = null; 
		boolean sta = false;
		try {
			stm = conn.prepareStatement(sql);
			stm.setString(1, admin);
			stm.setString(2, password);
			a = stm.executeUpdate();
			if(a == 0) {
				sta = false;
			}else {
				sta = true;
			}
			
			return sta;
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}	
	}
	//登录
	public static boolean login(String admin,String password) {
		Connection conn = DBUtil.getConnectDb();
		String sql = "select * from auser where admin=? and password=?";
		ResultSet rs;
		PreparedStatement stm = null; 
		boolean sta = false;
		try {
			stm = conn.prepareStatement(sql);
			stm.setString(1, admin);
			stm.setString(2, password);
			rs = stm.executeQuery();
			if(rs.next()) {
				sta = true;
			}else {
				sta = false;
			}
			
			return sta;
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}	
	}
	
}

StudentDao.java

package com.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import com.bean.StudentBean;
import com.util.DBUtil;
public class StudentDao {
	
	//添加
	public static boolean addStudent(String sid,String sname,String scls,String age,String major) {
		Connection conn = DBUtil.getConnectDb();
		String sql = "INSERT INTO stus VALUES(?,?,?,?,?)";
		int rs;
		PreparedStatement stm = null;
		try {
			stm = conn.prepareStatement(sql);
			stm.setString(1,sid);
			stm.setString(2,sname);
			stm.setString(3,scls);
			stm.setString(4,age);
			stm.setString(5,major);
			boolean a = false;
			rs = stm.executeUpdate();
			if(rs == 1) {
				return true;
			}else {
				return false;
			}
		}catch (SQLException e) {
			// TODO: handle exception
			e.printStackTrace();
			return false;
		}
	}
	
	//更改
	public static boolean updateStudent(String sid,String sname,String scls,String age,String major) {
		Connection conn = DBUtil.getConnectDb();
		String sql = "UPDATE stus SET sname=?,scls=?,age=?,major=? WHERE sid=?";
		int rs;
		PreparedStatement stm = null;
		try {
			stm = conn.prepareStatement(sql);
			stm.setString(1,sname);
			stm.setString(2,scls);
			stm.setString(3,age);
			stm.setString(4,major);
			stm.setString(5,sid);
			boolean a = false;
			rs = stm.executeUpdate();
			if(rs == 1) {
				return true;
			}else {
				return false;
			}
		}catch (SQLException e) {
			// TODO: handle exception
			e.printStackTrace();
			return false;
		}
	}
	
	//删除
		public static boolean deleteStudent(String sid) {
			Connection conn = DBUtil.getConnectDb();
			String sql = "DELETE FROM stus WHERE sid=?";
			int rs;
			PreparedStatement stm = null;
			try {
				stm = conn.prepareStatement(sql);
				stm.setString(1,sid);
				boolean a = false;
				rs = stm.executeUpdate();
				if(rs == 1) {
					return true;
				}else {
					return false;
				}
			}catch (SQLException e) {
				// TODO: handle exception
				e.printStackTrace();
				return false;
			}
		}
		
		//查询所有信息
		public static ArrayList getList() {
			ArrayList studentArray = new ArrayList();   
			Connection conn = DBUtil.getConnectDb();
			String sql = "SELECT * FROM stus";
			PreparedStatement stm = null;
			ResultSet rs = null;
			
				try {
					stm = conn.prepareStatement(sql);
					rs = stm.executeQuery();
					
					while (rs.next()) {
						StudentBean m = new StudentBean();
						m.setSid(rs.getString("sid"));
						m.setSname(rs.getString("sname"));
						m.setScls(rs.getString("scls"));
						m.setAge(rs.getString("age"));
						m.setMajor(rs.getString("major"));
						studentArray.add(m);
					}
					rs.close();
					stm.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return studentArray;
		}
		
		//查询单个学生信息
				public static ArrayList getList(String sid) {
					ArrayList studentArray = new ArrayList();   //建立一个数组集合
					Connection conn = DBUtil.getConnectDb();
					String sql = "SELECT * FROM stus WHERE sid=?";
					PreparedStatement stm = null;
					ResultSet rs = null;
					
						try {
							stm = conn.prepareStatement(sql);
							stm.setString(1,sid);
							rs = stm.executeQuery();
							
							while (rs.next()) {
								StudentBean m = new StudentBean();
								m.setSid(rs.getString("sid"));
								m.setSname(rs.getString("sname"));
								m.setScls(rs.getString("scls"));
								m.setAge(rs.getString("age"));
								m.setMajor(rs.getString("major"));
								studentArray.add(m);
							}
							rs.close();
							stm.close();
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						return studentArray;
				}
}

LoginFilter.java

package com.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@WebFilter("/*")
public class LoginFilter implements Filter {
	@Override
	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
			throws IOException, ServletException {
		// TODO Auto-generated method stub
		HttpServletRequest request = (HttpServletRequest)req;
		HttpServletResponse response = (HttpServletResponse)res;
		HttpSession session = request.getSession();
		
		String requestURI = request.getRequestURI();
		System.out.println(requestURI);
		if(requestURI.contains("/login.jsp")
				||requestURI.contains("/LoginServlet")
				||requestURI.contains("/LoginDelete")
				||requestURI.contains("/register.jsp")
				||requestURI.contains("/Login.css")
				||requestURI.contains("/Register.css")
				||requestURI.contains("/RegisterServlet")) {
			chain.doFilter(req, res);
			return;
		}
		
		if(session.getAttribute("username")!=null) {
			chain.doFilter(req, res);
		}else{
			response.sendRedirect("login.jsp");
		}
	}
}

AddStudentServlet.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 com.dao.StudentDao;
/**
 * Servlet implementation class AddStudentServlet
 */
@WebServlet("/AddStudentServlet")
public class AddStudentServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AddStudentServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		
		String id = request.getParameter("sid");
		String name = request.getParameter("sname");
		String cls = request.getParameter("scls");
		String age = request.getParameter("age");
		String major = request.getParameter("major");
		
		
		boolean a = StudentDao.addStudent(id, name, cls, age, major);
		if(a == true) {
			request.getSession().setAttribute("B2", "添加学生信息成功!");
			response.sendRedirect("/StudentsMessageDemo/index.jsp");
		}else {
			
			request.getSession().setAttribute("B2", "添加失败,请检查学号!");
			response.sendRedirect("/StudentsMessageDemo/index.jsp");
		}
		
	}
}

DeleteStudentServlet.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 com.dao.StudentDao;
/**
 * Servlet implementation class DeleteStudentServlet
 */
@WebServlet("/DeleteStudentServlet")
public class DeleteStudentServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DeleteStudentServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		
		String id = request.getParameter("sid");
		
		boolean a = StudentDao.deleteStudent(id);
		
		if(a == true) {
			request.getSession().setAttribute("B1", "删除学生信息成功!");
			response.sendRedirect("/StudentsMessageDemo/index.jsp");
		}else {
			
			request.getSession().setAttribute("B1", "删除学生信息失败!");
			
			response.sendRedirect("/StudentsMessageDemo/index.jsp");
		}
		
	}
}

LoginOut.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;
/**
 * Servlet implementation class LoginOut
 */
@WebServlet("/LoginOut")
public class LoginOut extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public LoginOut() {
        super();
        // TODO Auto-generated constructor stub
    }
	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		request.getSession().invalidate();
		
		response.sendRedirect("/StudentsMessageDemo/login.jsp");
	}
}

LoginServlet.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.servlet.http.HttpSession;
import com.dao.AdminDao;
/**
 * Servlet implementation class LoginServlet
 */
@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public LoginServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		
		//获取注册信息
		String username = request.getParameter("u");
		String password = request.getParameter("p");
		
		boolean a = AdminDao.login(username, password);
		
		//登录
		
		if(a == true) {
			HttpSession session = request.getSession();
			//将username保存在session中
			session.setAttribute("username",username);
			
			response.sendRedirect("/StudentsMessageDemo/index.jsp");
		}else {
			
			request.getSession().setAttribute("A2", "账号或密码错误请重新登录!");
			
			response.sendRedirect("/StudentsMessageDemo/login.jsp");
		}
		
	}
}

RegisterServlet.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 com.dao.AdminDao;
/**
 * Servlet implementation class RegisterServlet
 */
@WebServlet("/RegisterServlet")
public class RegisterServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RegisterServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		
		//获取注册信息
		String username = request.getParameter("u");
		String password = request.getParameter("p");
		
		boolean a = AdminDao.register(username, password);
		
		//将注册信息存入数据库,在返回登录
		
		if(a == true) {
			
			request.getSession().setAttribute("A1", "注册账号成功!");
			response.sendRedirect("/StudentsMessageDemo/register.jsp");
		}else {
			request.getSession().setAttribute("A1", "注册账号失败!");
			response.sendRedirect("/StudentsMessageDemo/register.jsp");
		}
		
	}
}

SelectStudentServlet.java

package com.servlet;
import java.io.IOException;
import java.util.ArrayList;
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.StudentDao;
/**
 * Servlet implementation class SelectStudentServlet
 */
@WebServlet("/SelectStudentServlet")
public class SelectStudentServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SelectStudentServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		
		//获取注册信息
		String id = request.getParameter("sid");
		
		ArrayList a;
		if(id.equals("")) {
			a = StudentDao.getList();
			request.getSession().setAttribute("B1", "查询学生信息成功!");
		}else {
			a = StudentDao.getList(id);
			
		}
		request.getSession().setAttribute("stuMessage", a);
		//System.out.println(a);
		response.sendRedirect("/StudentsMessageDemo/index.jsp");
	}
}

UpdateStudentServlet.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 com.dao.StudentDao;
/**
 * Servlet implementation class UpdateStudentServlet
 */
@WebServlet("/UpdateStudentServlet")
public class UpdateStudentServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UpdateStudentServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		
		//获取注册信息
		String id = request.getParameter("sid");
		String name = request.getParameter("sname");
		String cls = request.getParameter("scls");
		String age = request.getParameter("age");
		String major = request.getParameter("major");
		
		boolean a = StudentDao.updateStudent(id, name, cls, age, major);
		//登录
		
		if(a == true) {
			request.getSession().setAttribute("B2", "修改学生信息成功!");
			response.sendRedirect("/StudentsMessageDemo/index.jsp");
		}else {
			
			request.getSession().setAttribute("B2", "修改失败,请检查学号!");
			
			response.sendRedirect("/StudentsMessageDemo/index.jsp");
		}
		
	}
}

DBUtil.java

package com.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBUtil {
	
	public static String url="jdbc:mysql://localhost:3306/students?serverTimezone=UTC&useSSL=true&characterEncoding=utf-8";
	public static String username="root";
	public static String password="";//密码根据自己的自行添加
	static {
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} 
		catch (Exception e) {
			System.out.println(e);
		}
	}
	public static Connection getConnectDb() {
		Connection conn = null;
		try {
			System.out.println("正在连接数据库....");
			conn=DriverManager.getConnection(url,username,password);
			System.out.println("连接成功");
		} 
		catch (SQLException  e) {
			System.out.println(e);
		}
		return conn;
	}
	
}

web.xml



  StudentsMessageDemo
  
    index.html
    index.jsp
    index.htm
    default.html
    default.jsp
    default.htm
  
  

	LoginFilter
	com.filter.LoginFilter


	LoginFilter
	/*

数据库:

JAVAWEB学生信息管理系统保姆级教程(增删改查+登录注册+Filter+mysql)eclipse版,第3张

 JAVAWEB学生信息管理系统保姆级教程(增删改查+登录注册+Filter+mysql)eclipse版,第4张

最终效果图:

登陆界面

JAVAWEB学生信息管理系统保姆级教程(增删改查+登录注册+Filter+mysql)eclipse版,第5张

注册界面 

JAVAWEB学生信息管理系统保姆级教程(增删改查+登录注册+Filter+mysql)eclipse版,第6张

主界面 

JAVAWEB学生信息管理系统保姆级教程(增删改查+登录注册+Filter+mysql)eclipse版,第7张