Giter Site home page Giter Site logo

info-management-system's Introduction

🌈 bootstrap+JavaSE+JDBC的信息管理系统

介绍

使用bootstrap+JavaEE+JDBC+JSP+Ajax页面;实现一个用户信息的增删改查功能

源码

1.0 没有使用ajax技术,无模糊查询功能

jsp-v1.0版本

2.0 注册用户使用ajax,无模糊查询功能

jsp-v2.0版本

3.0 展示数据采用ajax,模糊查询采用ajax

jsp-v3.0版本

4.0 防止用户跳过登录和免登陆采用filter过滤器

jsp-v4.0版本

下载对应版本即可!

Bug

  1. 注册时只对用户名和密码进行正则验证,只输入用户名和密码,直接注册会成功!

2021/9/18 v2.0

  1. 新增ajax,用户名注册验证,数据库是否存在已经注册的用户账号
  2. 注册新增,ajax注册,注册可使用表单的post请求和ajax的post请求
  3. 解决免登陆问题,登录后点击添加用户,再点击登录页面,会一直在注册页面

2021/9/29 v3.0

  1. 修改展示数据的方式,改为ajax请求
  2. 新增模糊查询用户账号

2021/10/9 v4.0

  1. 删除check.jsp和cookie.jsp,采用filter过滤器判断用户是否登录和免登陆
  2. filter进行传统配置和注解配置混合的方法

项目结构

4.0

数据库设计

用户表(账号,密码,性别,学历,爱好)
create table d_student(
account varchar(50) primary key,
pwd varchar(50) not null,
sex varchar(10) not null,
educ varchar(10) not null,
happy varchar(50) not null
)default charset=utf8;

主要功能

  1. 注册,登录,登出
  2. cookie 30s内免登录
  3. session防止用户直接输入网站登录
  4. 查看用户信息,并修改
  5. 删除用户信息

注意 :本系统可使用任何账号操作所有用户的信息!!!

页面效果

登录

登录页面

注册

注册

模糊查询

ajax展示数据,注册,模糊查询

用户列表

登录进入-用户列表页面

用户详情

用户详情页面

db.properties

本数据库配置文件与 src 同级

#通过反射获取获取包
driverClassName=com.mysql.jc.jdbc.Driver #8.0
#driverClassName=com.mysql.jdbc.Driver #5.0 数据库版本
# localhost 本地服务器
# 3306 端口
# demo 数据库名
# &useSSL=false&serverTimezone=UTC 数据库版本5.0左右可去除,我使用的是8.0以上的版本,&作为参数的连接符
url=jdbc:mysql://localhost:3306/demo?characterEncoding=utf8&useSSL=false&serverTimezone=UTC

# 用户名
username=root

# 密码
password=root

utils

使用德鲁伊连接池和QueryRunner处理数据,需要导包

package com.utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;
import java.sql.Connection;
import java.util.Properties;

/**
 * @author 涂鏊飞[email protected]
 * @description: 数据库操作工具类 类描述
 * @create 2021-09-01 17:18
 */
public class JdbcUtils {
    private static DataSource ds;
    static {
        try {
            //1.加载配置文件
            Properties pro = new Properties();
            pro.load(JdbcUtils.class.getClassLoader().getResourceAsStream("db.properties"));
            //2.获取DataSource
            ds = DruidDataSourceFactory.createDataSource(pro);
        }
        catch (Exception e){
            ds = null;
        }
    }

    private static Connection getConnection(){
        Connection con;
        try {
            con = ds.getConnection();
        }
        catch (Exception ex){
            con = null;
        }
        return con;
    }
    /* 获取 QueryRunner */
    public static QueryRunner getQueryRunner(){
        QueryRunner runner = new QueryRunner(ds);
        return runner;
    }
}

pojo层

数据库中的表对应的实体类: Student.java

dao层

StudentDao接口

public interface StudentDao
抽象方法
1️⃣ public Integer insertStudent(Student student) throws SQLException; //插入数据
2️⃣ public List<Student> selectAll() throws SQLException; // 查询所有用户信息
3️⃣ public Student selectOne(String stuName) throws SQLException;// 查询单个用户信息
4️⃣ public Integer delOne(String stuName) throws SQLException; // 删除单个用户信息
5️⃣ public Integer alterOne(Student student) throws SQLException; //修改单个用户信息
6️⃣ public List<Student> selectAll(String acc) throws SQLException;//模糊查询用户名

service层

接口和dao层相同

public interface StudentService {
    public Integer insertStudent(Student student) throws SQLException;
    public List<Student> selectAll() throws SQLException;
    public List<Student> selectAll(String acc) throws SQLException;
    public Student selectOne(String stuName) throws SQLException;
    public Integer delOne(String stuName) throws SQLException;
    public Integer alterOne(Student student) throws SQLException;
}

web层,servlet

servlet

web目录 v1.0可用

输入图片说明 WEB-INF 目录下的包含 web.xml 文件配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
<!--    默认页面-->
    <welcome-file-list>
        <welcome-file>bootstrap_register.jsp</welcome-file>
    </welcome-file-list>
<!--    session失效时间30分钟-->
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
</web-app>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.