IDEA+Java+Servlet+JSP+Bootstrap+Mysql实现Web学生宿舍管理系统(下)

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介: IDEA+Java+Servlet+JSP+Bootstrap+Mysql实现Web学生宿舍管理系统

RecordDao

package com.lero.dao;
import com.lero.model.DormBuild;
import com.lero.model.Record;
import com.lero.util.StringUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class RecordDao {
    public List<Record> recordList(Connection con, Record s_record) throws Exception {
        List<Record> recordList = new ArrayList<Record>();
        StringBuffer sb = new StringBuffer("select * from t_record t1");
        if (StringUtil.isNotEmpty(s_record.getStudentNumber())) {
            sb.append(" and t1.studentNumber like '%" + s_record.getStudentNumber() + "%'");
        } else if (StringUtil.isNotEmpty(s_record.getStudentName())) {
            sb.append(" and t1.studentName like '%" + s_record.getStudentName() + "%'");
        }
        if (s_record.getDormBuildId() != 0) {
            sb.append(" and t1.dormBuildId=" + s_record.getDormBuildId());
        }
        if (StringUtil.isNotEmpty(s_record.getDate())) {
            sb.append(" and t1.date=" + s_record.getDate());
        }
        if (StringUtil.isNotEmpty(s_record.getStartDate())) {
            sb.append(" and TO_DAYS(t1.date)>=TO_DAYS('" + s_record.getStartDate() + "')");
        }
        if (StringUtil.isNotEmpty(s_record.getEndDate())) {
            sb.append(" and TO_DAYS(t1.date)<=TO_DAYS('" + s_record.getEndDate() + "')");
        }
        PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            Record record = new Record();
            record.setRecordId(rs.getInt("recordId"));
            record.setStudentNumber(rs.getString("studentNumber"));
            record.setStudentName(rs.getString("studentName"));
            int dormBuildId = rs.getInt("dormBuildId");
            record.setDormBuildId(dormBuildId);
            record.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
            record.setDormName(rs.getString("dormName"));
            record.setDate(rs.getString("date"));
            record.setDetail(rs.getString("detail"));
            recordList.add(record);
        }
        return recordList;
    }
    public List<Record> recordListWithBuild(Connection con, Record s_record, int buildId) throws Exception {
        List<Record> recordList = new ArrayList<Record>();
        StringBuffer sb = new StringBuffer("select * from t_record t1");
        if (StringUtil.isNotEmpty(s_record.getStudentNumber())) {
            sb.append(" and t1.studentNumber like '%" + s_record.getStudentNumber() + "%'");
        } else if (StringUtil.isNotEmpty(s_record.getStudentName())) {
            sb.append(" and t1.studentName like '%" + s_record.getStudentName() + "%'");
        }
        sb.append(" and t1.dormBuildId=" + buildId);
        if (StringUtil.isNotEmpty(s_record.getStartDate())) {
            sb.append(" and TO_DAYS(t1.date)>=TO_DAYS('" + s_record.getStartDate() + "')");
        }
        if (StringUtil.isNotEmpty(s_record.getEndDate())) {
            sb.append(" and TO_DAYS(t1.date)<=TO_DAYS('" + s_record.getEndDate() + "')");
        }
        PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            Record record = new Record();
            record.setRecordId(rs.getInt("recordId"));
            record.setStudentNumber(rs.getString("studentNumber"));
            record.setStudentName(rs.getString("studentName"));
            int dormBuildId = rs.getInt("dormBuildId");
            record.setDormBuildId(dormBuildId);
            record.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
            record.setDormName(rs.getString("dormName"));
            record.setDate(rs.getString("date"));
            record.setDetail(rs.getString("detail"));
            recordList.add(record);
        }
        return recordList;
    }
    public List<Record> recordListWithNumber(Connection con, Record s_record, String studentNumber) throws Exception {
        List<Record> recordList = new ArrayList<Record>();
        StringBuffer sb = new StringBuffer("select * from t_record t1");
        if (StringUtil.isNotEmpty(studentNumber)) {
            sb.append(" and t1.studentNumber =" + studentNumber);
        }
        if (StringUtil.isNotEmpty(s_record.getStartDate())) {
            sb.append(" and TO_DAYS(t1.date)>=TO_DAYS('" + s_record.getStartDate() + "')");
        }
        if (StringUtil.isNotEmpty(s_record.getEndDate())) {
            sb.append(" and TO_DAYS(t1.date)<=TO_DAYS('" + s_record.getEndDate() + "')");
        }
        PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            Record record = new Record();
            record.setRecordId(rs.getInt("recordId"));
            record.setStudentNumber(rs.getString("studentNumber"));
            record.setStudentName(rs.getString("studentName"));
            int dormBuildId = rs.getInt("dormBuildId");
            record.setDormBuildId(dormBuildId);
            record.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
            record.setDormName(rs.getString("dormName"));
            record.setDate(rs.getString("date"));
            record.setDetail(rs.getString("detail"));
            recordList.add(record);
        }
        return recordList;
    }
    public List<DormBuild> dormBuildList(Connection con) throws Exception {
        List<DormBuild> dormBuildList = new ArrayList<DormBuild>();
        String sql = "select * from t_dormBuild";
        PreparedStatement pstmt = con.prepareStatement(sql);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            DormBuild dormBuild = new DormBuild();
            dormBuild.setDormBuildId(rs.getInt("dormBuildId"));
            dormBuild.setDormBuildName(rs.getString("dormBuildName"));
            dormBuild.setDetail(rs.getString("dormBuildDetail"));
            dormBuildList.add(dormBuild);
        }
        return dormBuildList;
    }
//  
//  public int studentCount(Connection con, Student s_student)throws Exception {
//    StringBuffer sb = new StringBuffer("select count(*) as total from t_student t1");
//    if(StringUtil.isNotEmpty(s_student.getName())) {
//      sb.append(" and t1.name like '%"+s_student.getName()+"%'");
//    } else if(StringUtil.isNotEmpty(s_student.getStuNumber())) {
//      sb.append(" and t1.stuNum like '%"+s_student.getStuNumber()+"%'");
//    } else if(StringUtil.isNotEmpty(s_student.getDormName())) {
//      sb.append(" and t1.dormName like '%"+s_student.getDormName()+"%'");
//    }
//    if(s_student.getDormBuildId()!=0) {
//      sb.append(" and t1.dormBuildId="+s_student.getDormBuildId());
//    }
//    PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
//    ResultSet rs = pstmt.executeQuery();
//    if(rs.next()) {
//      return rs.getInt("total");
//    } else {
//      return 0;
//    }
//  }
    public Record recordShow(Connection con, String recordId) throws Exception {
        String sql = "select * from t_record t1 where t1.recordId=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, recordId);
        ResultSet rs = pstmt.executeQuery();
        Record record = new Record();
        if (rs.next()) {
            record.setRecordId(rs.getInt("recordId"));
            record.setStudentNumber(rs.getString("studentNumber"));
            record.setStudentName(rs.getString("studentName"));
            int dormBuildId = rs.getInt("dormBuildId");
            record.setDormBuildId(dormBuildId);
            record.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
            record.setDormName(rs.getString("dormName"));
            record.setDate(rs.getString("date"));
            record.setDetail(rs.getString("detail"));
        }
        return record;
    }
    public int recordAdd(Connection con, Record record) throws Exception {
        String sql = "insert into t_record values(null,?,?,?,?,?,?)";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, record.getStudentNumber());
        pstmt.setString(2, record.getStudentName());
        pstmt.setInt(3, record.getDormBuildId());
        pstmt.setString(4, record.getDormName());
        pstmt.setString(5, record.getDate());
        pstmt.setString(6, record.getDetail());
        return pstmt.executeUpdate();
    }
    public int recordDelete(Connection con, String recordId) throws Exception {
        String sql = "delete from t_record where recordId=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, recordId);
        return pstmt.executeUpdate();
    }
    public int recordUpdate(Connection con, Record record) throws Exception {
        String sql = "update t_record set studentNumber=?,studentName=?,dormBuildId=?,dormName=?,detail=? where recordId=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, record.getStudentNumber());
        pstmt.setString(2, record.getStudentName());
        pstmt.setInt(3, record.getDormBuildId());
        pstmt.setString(4, record.getDormName());
        pstmt.setString(5, record.getDetail());
        pstmt.setInt(6, record.getRecordId());
        return pstmt.executeUpdate();
    }
}

StudentDao

package com.lero.dao;
import com.lero.model.DormBuild;
import com.lero.model.Student;
import com.lero.util.StringUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class StudentDao {
//  public List<Student> studentList(Connection con, PageBean pageBean, Student s_student)throws Exception {
//    List<Student> studentList = new ArrayList<Student>();
//    StringBuffer sb = new StringBuffer("select * from t_student t1");
//    if(StringUtil.isNotEmpty(s_student.getName())) {
//      sb.append(" and t1.name like '%"+s_student.getName()+"%'");
//    } else if(StringUtil.isNotEmpty(s_student.getStuNumber())) {
//      sb.append(" and t1.stuNum like '%"+s_student.getStuNumber()+"%'");
//    } else if(StringUtil.isNotEmpty(s_student.getDormName())) {
//      sb.append(" and t1.dormName like '%"+s_student.getDormName()+"%'");
//    }
//    if(s_student.getDormBuildId()!=0) {
//      sb.append(" and t1.dormBuildId="+s_student.getDormBuildId());
//    }
//    if(pageBean != null) {
//      sb.append(" limit "+pageBean.getStart()+","+pageBean.getPageSize());
//    }
//    PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
//    ResultSet rs = pstmt.executeQuery();
//    while(rs.next()) {
//      Student student=new Student();
//      student.setStudentId(rs.getInt("studentId"));
//      int dormBuildId = rs.getInt("dormBuildId");
//      student.setDormBuildId(dormBuildId);
//      student.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
//      student.setDormName(rs.getString("dormName"));
//      student.setName(rs.getString("name"));
//      student.setSex(rs.getString("sex"));
//      student.setStuNumber(rs.getString("stuNum"));
//      student.setTel(rs.getString("tel"));
//      student.setPassword(rs.getString("password"));
//      studentList.add(student);
//    }
//    return studentList;
//  }
    public static Student getNameById(Connection con, String studentNumber, int dormBuildId) throws Exception {
        String sql = "select * from t_student t1 where t1.stuNum=? and t1.dormBuildId=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, studentNumber);
        pstmt.setInt(2, dormBuildId);
        ResultSet rs = pstmt.executeQuery();
        Student student = new Student();
        if (rs.next()) {
            student.setName(rs.getString("name"));
            student.setDormBuildId(rs.getInt("dormBuildId"));
            student.setDormName(rs.getString("dormName"));
        }
        return student;
    }
    public List<Student> studentList(Connection con, Student s_student) throws Exception {
        List<Student> studentList = new ArrayList<Student>();
        StringBuffer sb = new StringBuffer("select * from t_student t1");
        if (StringUtil.isNotEmpty(s_student.getName())) {
            sb.append(" and t1.name like '%" + s_student.getName() + "%'");
        } else if (StringUtil.isNotEmpty(s_student.getStuNumber())) {
            sb.append(" and t1.stuNum like '%" + s_student.getStuNumber() + "%'");
        } else if (StringUtil.isNotEmpty(s_student.getDormName())) {
            sb.append(" and t1.dormName like '%" + s_student.getDormName() + "%'");
        }
        if (s_student.getDormBuildId() != 0) {
            sb.append(" and t1.dormBuildId=" + s_student.getDormBuildId());
        }
        PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            Student student = new Student();
            student.setStudentId(rs.getInt("studentId"));
            int dormBuildId = rs.getInt("dormBuildId");
            student.setDormBuildId(dormBuildId);
            student.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
            student.setDormName(rs.getString("dormName"));
            student.setName(rs.getString("name"));
            student.setSex(rs.getString("sex"));
            student.setStuNumber(rs.getString("stuNum"));
            student.setTel(rs.getString("tel"));
            student.setPassword(rs.getString("password"));
            studentList.add(student);
        }
        return studentList;
    }
    public boolean haveNameByNumber(Connection con, String studentNumber) throws Exception {
        String sql = "select * from t_student t1 where t1.stuNum=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, studentNumber);
        ResultSet rs = pstmt.executeQuery();
        Student student = new Student();
        if (rs.next()) {
            student.setName(rs.getString("name"));
            student.setDormBuildId(rs.getInt("dormBuildId"));
            student.setDormName(rs.getString("dormName"));
            return true;
        }
        return false;
    }
    public List<Student> studentListWithBuild(Connection con, Student s_student, int buildId) throws Exception {
        List<Student> studentList = new ArrayList<Student>();
        StringBuffer sb = new StringBuffer("select * from t_student t1");
        if (StringUtil.isNotEmpty(s_student.getName())) {
            sb.append(" and t1.name like '%" + s_student.getName() + "%'");
        } else if (StringUtil.isNotEmpty(s_student.getStuNumber())) {
            sb.append(" and t1.stuNum like '%" + s_student.getStuNumber() + "%'");
        } else if (StringUtil.isNotEmpty(s_student.getDormName())) {
            sb.append(" and t1.dormName like '%" + s_student.getDormName() + "%'");
        }
        sb.append(" and t1.dormBuildId=" + buildId);
        PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            Student student = new Student();
            student.setStudentId(rs.getInt("studentId"));
            int dormBuildId = rs.getInt("dormBuildId");
            student.setDormBuildId(dormBuildId);
            student.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
            student.setDormName(rs.getString("dormName"));
            student.setName(rs.getString("name"));
            student.setSex(rs.getString("sex"));
            student.setStuNumber(rs.getString("stuNum"));
            student.setTel(rs.getString("tel"));
            student.setPassword(rs.getString("password"));
            studentList.add(student);
        }
        return studentList;
    }
    public List<DormBuild> dormBuildList(Connection con) throws Exception {
        List<DormBuild> dormBuildList = new ArrayList<DormBuild>();
        String sql = "select * from t_dormBuild";
        PreparedStatement pstmt = con.prepareStatement(sql);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            DormBuild dormBuild = new DormBuild();
            dormBuild.setDormBuildId(rs.getInt("dormBuildId"));
            dormBuild.setDormBuildName(rs.getString("dormBuildName"));
            dormBuild.setDetail(rs.getString("dormBuildDetail"));
            dormBuildList.add(dormBuild);
        }
        return dormBuildList;
    }
    public int studentCount(Connection con, Student s_student) throws Exception {
        StringBuffer sb = new StringBuffer("select count(*) as total from t_student t1");
        if (StringUtil.isNotEmpty(s_student.getName())) {
            sb.append(" and t1.name like '%" + s_student.getName() + "%'");
        } else if (StringUtil.isNotEmpty(s_student.getStuNumber())) {
            sb.append(" and t1.stuNum like '%" + s_student.getStuNumber() + "%'");
        } else if (StringUtil.isNotEmpty(s_student.getDormName())) {
            sb.append(" and t1.dormName like '%" + s_student.getDormName() + "%'");
        }
        if (s_student.getDormBuildId() != 0) {
            sb.append(" and t1.dormBuildId=" + s_student.getDormBuildId());
        }
        PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
        ResultSet rs = pstmt.executeQuery();
        if (rs.next()) {
            return rs.getInt("total");
        } else {
            return 0;
        }
    }
    public Student studentShow(Connection con, String studentId) throws Exception {
        String sql = "select * from t_student t1 where t1.studentId=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, studentId);
        ResultSet rs = pstmt.executeQuery();
        Student student = new Student();
        if (rs.next()) {
            student.setStudentId(rs.getInt("studentId"));
            int dormBuildId = rs.getInt("dormBuildId");
            student.setDormBuildId(dormBuildId);
            student.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
            student.setDormName(rs.getString("dormName"));
            student.setName(rs.getString("name"));
            student.setSex(rs.getString("sex"));
            student.setStuNumber(rs.getString("stuNum"));
            student.setTel(rs.getString("tel"));
            student.setPassword(rs.getString("password"));
        }
        return student;
    }
    public int studentAdd(Connection con, Student student) throws Exception {
        String sql = "insert into t_student values(null,?,?,?,?,?,?,?)";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, student.getStuNumber());
        pstmt.setString(2, student.getPassword());
        pstmt.setString(3, student.getName());
        pstmt.setInt(4, student.getDormBuildId());
        pstmt.setString(5, student.getDormName());
        pstmt.setString(6, student.getSex());
        pstmt.setString(7, student.getTel());
        return pstmt.executeUpdate();
    }
    public int studentDelete(Connection con, String studentId) throws Exception {
        String sql = "delete from t_student where studentId=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, studentId);
        return pstmt.executeUpdate();
    }
    public int studentUpdate(Connection con, Student student) throws Exception {
        String sql = "update t_student set stuNum=?,password=?,name=?,dormBuildId=?,dormName=?,sex=?,tel=? where studentId=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, student.getStuNumber());
        pstmt.setString(2, student.getPassword());
        pstmt.setString(3, student.getName());
        pstmt.setInt(4, student.getDormBuildId());
        pstmt.setString(5, student.getDormName());
        pstmt.setString(6, student.getSex());
        pstmt.setString(7, student.getTel());
        pstmt.setInt(8, student.getStudentId());
        return pstmt.executeUpdate();
    }
}

UserDao

package com.lero.dao;
import com.lero.model.Admin;
import com.lero.model.DormManager;
import com.lero.model.Student;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class UserDao {
    public Admin Login(Connection con, Admin admin) throws Exception {
        Admin resultAdmin = null;
        String sql = "select * from t_admin where userName=? and password=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, admin.getUserName());
        pstmt.setString(2, admin.getPassword());
        ResultSet rs = pstmt.executeQuery();
        if (rs.next()) {
            resultAdmin = new Admin();
            resultAdmin.setAdminId(rs.getInt("adminId"));
            resultAdmin.setUserName(rs.getString("userName"));
            resultAdmin.setPassword(rs.getString("password"));
            resultAdmin.setName(rs.getString("name"));
            resultAdmin.setSex(rs.getString("sex"));
            resultAdmin.setTel(rs.getString("tel"));
        }
        return resultAdmin;
    }
    public DormManager Login(Connection con, DormManager dormManager) throws Exception {
        DormManager resultDormManager = null;
        String sql = "select * from t_dormmanager where userName=? and password=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, dormManager.getUserName());
        pstmt.setString(2, dormManager.getPassword());
        ResultSet rs = pstmt.executeQuery();
        if (rs.next()) {
            resultDormManager = new DormManager();
            resultDormManager.setDormManagerId(rs.getInt("dormManId"));
            resultDormManager.setUserName(rs.getString("userName"));
            resultDormManager.setPassword(rs.getString("password"));
            resultDormManager.setDormBuildId(rs.getInt("dormBuildId"));
            resultDormManager.setName(rs.getString("name"));
            resultDormManager.setSex(rs.getString("sex"));
            resultDormManager.setTel(rs.getString("tel"));
        }
        return resultDormManager;
    }
    public Student Login(Connection con, Student student) throws Exception {
        Student resultStudent = null;
        String sql = "select * from t_student where stuNum=? and password=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, student.getStuNumber());
        pstmt.setString(2, student.getPassword());
        ResultSet rs = pstmt.executeQuery();
        if (rs.next()) {
            resultStudent = new Student();
            resultStudent.setStudentId(rs.getInt("studentId"));
            resultStudent.setStuNumber(rs.getString("stuNum"));
            resultStudent.setPassword(rs.getString("password"));
            int dormBuildId = rs.getInt("dormBuildId");
            resultStudent.setDormBuildId(dormBuildId);
            resultStudent.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
            resultStudent.setDormName(rs.getString("dormName"));
            resultStudent.setName(rs.getString("name"));
            resultStudent.setSex(rs.getString("sex"));
            resultStudent.setTel(rs.getString("tel"));
        }
        return resultStudent;
    }
    public int adminUpdate(Connection con, int adminId, String password) throws Exception {
        String sql = "update t_admin set password=? where adminId=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, password);
        pstmt.setInt(2, adminId);
        return pstmt.executeUpdate();
    }
    public int managerUpdate(Connection con, int managerId, String password) throws Exception {
        String sql = "update t_dormmanager set password=? where dormManId=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, password);
        pstmt.setInt(2, managerId);
        return pstmt.executeUpdate();
    }
    public int studentUpdate(Connection con, int studentId, String password) throws Exception {
        String sql = "update t_student set password=? where studentId=?";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setString(1, password);
        pstmt.setInt(2, studentId);
        return pstmt.executeUpdate();
    }
}

PropertiesUtil

package com.lero.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class PropertiesUtil {
    public static String getValue(String key) {
        Properties prop = new Properties();
        InputStream in = new PropertiesUtil().getClass().getResourceAsStream("/dorm.properties");
        try {
            prop.load(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return (String) prop.get(key);
    }
}

login.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" %>
<%@ page import="com.lero.model.Admin" %>
<%@ page import="com.lero.model.DormManager" %>
<%@ page import="com.lero.model.Student" %>
<%
    if (request.getAttribute("user") == null) {
        String userName = null;
        String password = null;
        String userType = null;
        String remember = null;
        Cookie[] cookies = request.getCookies();
        for (int i = 0; cookies != null && i < cookies.length; i++) {
            if (cookies[i].getName().equals("dormuser")) {
                userName = cookies[i].getValue().split("-")[0];
                password = cookies[i].getValue().split("-")[1];
                userType = cookies[i].getValue().split("-")[2];
                remember = cookies[i].getValue().split("-")[3];
            }
        }
        if (userName == null) {
            userName = "";
        }
        if (password == null) {
            password = "";
        }
        if (userType == null) {
            userType = "";
        } else if ("admin".equals(userType)) {
            pageContext.setAttribute("user", new Admin(userName, password));
            pageContext.setAttribute("userType", 1);
        } else if ("dormManager".equals(userType)) {
            pageContext.setAttribute("user", new DormManager(userName, password));
            pageContext.setAttribute("userType", 2);
        } else if ("student".equals(userType)) {
            pageContext.setAttribute("user", new Student(userName, password));
            pageContext.setAttribute("userType", 3);
        }
        if ("yes".equals(remember)) {
            pageContext.setAttribute("remember", 1);
        }
    }
%>
<html lang="zh">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>宿舍管理系统登录</title>
    <link href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/bootstrap/js/jQuery.js"></script>
    <script src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript">
        function checkForm() {
            var userName = document.getElementById("userName").value;
            var password = document.getElementById("password").value;
            var userTypes = document.getElementsByName("userType");
            var userType = null;
            for (var i = 0; i < userTypes.length; i++) {
                if (userTypes[i].checked) {
                    userType = userTypes[i].value;
                    break;
                }
            }
            if (userName == null || userName == "") {
                document.getElementById("error").innerHTML = "用户名不能为空";
                return false;
            }
            if (password == null || password == "") {
                document.getElementById("error").innerHTML = "密码不能为空";
                return false;
            }
            if (userType == null || userType == "") {
                document.getElementById("error").innerHTML = "请选择用户类型";
                return false;
            }
            return true;
        }
    </script>
    <style type="text/css">
        body {
            padding-top: 200px;
            padding-bottom: 40px;
            background-image: url('images/bg.jpg');
            background-position: center;
            background-repeat: no-repeat;
            background-attachment: fixed;
        }
        .radio {
            padding-top: 10px;
            padding-bottom: 10px;
        }
        .form-signin-heading {
            text-align: center;
        }
        .form-signin {
            max-width: 300px;
            padding: 19px 29px 0px;
            margin: 0 auto 20px;
            background-color: #fff;
            border: 1px solid #e5e5e5;
            -webkit-border-radius: 5px;
            -moz-border-radius: 5px;
            border-radius: 5px;
            -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
            -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
            box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
        }
        .form-signin .form-signin-heading,
        .form-signin .checkbox {
            margin-bottom: 10px;
        }
        .form-signin input[type="text"],
        .form-signin input[type="password"] {
            font-size: 16px;
            height: auto;
            margin-bottom: 15px;
            padding: 7px 9px;
        }
    </style>
</head>
<body>
<div class="container">
    <form name="myForm" class="form-signin" action="login" method="post" onsubmit="return checkForm()">
        <h2 class="form-signin-heading"><font color="gray">宿舍管理系统</font></h2>
        <input id="userName" name="userName" value="${user.userName }" type="text" class="input-block-level"
               placeholder="账号">
        <input id="password" name="password" value="${user.password }" type="password" class="input-block-level"
               placeholder="密码">
        <label class="radio inline">
            <input id="admin" type="radio" name="userType" value="admin" checked/> 系统管理员
        </label>
        <label class="radio inline">
            <input id="dormManager" type="radio" name="userType" value="dormManager" ${userType==2?'checked':''} />
            宿舍管理员
        </label>
        <label class="radio inline">
            <input id="student" type="radio" name="userType" value="student"  ${userType==3?'checked':''}/> 学生
        </label>
        <label class="checkbox">
            <input id="remember" name="remember" type="checkbox" value="remember-me" ${remember==1?'checked':''}>记住我
            &nbsp;&nbsp;&nbsp;&nbsp; <font id="error" color="red">${error }</font>
        </label>
        <button class="btn btn-large btn-primary" type="submit">登录</button>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <button class="btn btn-large btn-primary" type="button">重置</button>
        <p align="center" style="padding-top: 15px;">版权所有2021</p>
    </form>
</div>
</body>
</html>

mainAdmin.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" %>
<html lang="zh">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>宿舍管理系统</title>
    <link href="${pageContext.request.contextPath}/style/dorm.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/bootstrap-datetimepicker-master/css/bootstrap-datetimepicker.min.css"
          rel="stylesheet" media="screen">
    <link rel="stylesheet" type="text/css"
          href="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/dataTables.bootstra.css">
    <script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/jquery.js"></script>
    <script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/jquery.dataTables.js"></script>
    <script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/bootstrap.min.js"></script>
    <script type="text/javascript"
            src="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/dataTables.bootstrap.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js"
            charset="UTF-8"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/bootstrap-datetimepicker-master/js/locales/bootstrap-datetimepicker.fr.js"
            charset="UTF-8"></script>
    <script src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#DataTables_Table_0_wrapper .row-fluid").remove();
        });
    </script>
    <style type="text/css">
        .bs-docs-sidenav {
            background-color: #fff;
            border-radius: 6px;
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.067);
            padding: 0;
            width: 228px;
        }
        .bs-docs-sidenav > li > a {
            border: 1px solid #e5e5e5;
            display: block;
            padding: 8px 14px;
            margin: 0 0 -1px;
        }
        .bs-docs-sidenav > li:first-child > a {
            border-radius: 6px 6px 0 0;
        }
        .bs-docs-sidenav > li:last-child > a {
            border-radius: 0 0 6px 6px;
        }
        .bs-docs-sidenav > .active > a {
            border: 0 none;
            box-shadow: 1px 0 0 rgba(0, 0, 0, 0.1) inset, -1px 0 0 rgba(0, 0, 0, 0.1) inset;
            padding: 9px 15px;
            position: relative;
            text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
            z-index: 2;
        }
        .bs-docs-sidenav .icon-chevron-right {
            float: right;
            margin-right: -6px;
            margin-top: 2px;
            opacity: 0.25;
        }
        .bs-docs-sidenav > li > a:hover {
            background-color: #f5f5f5;
        }
        .bs-docs-sidenav a:hover .icon-chevron-right {
            opacity: 0.5;
        }
        .bs-docs-sidenav .active .icon-chevron-right, .bs-docs-sidenav .active a:hover .icon-chevron-right {
            background-image: url("../img/glyphicons-halflings-white.png");
            opacity: 1;
        }
    </style>
</head>
<body>
<div class="container-fluid" style="padding-right: 0px;padding-left: 0px;">
    <div region="north" style="height: 100px;background-image: url('images/bg.jpg')">
        <div align="left" style="width: 80%;height:100px ;float: left;padding-top: 40px;padding-left: 30px;"><font
                color="white" size="6">宿舍管理系统</font></div>
        <div style="padding-top: 70px;padding-right: 20px;">当前用户:&nbsp;<font color="red">${currentUser.userName }</font>
        </div>
    </div>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span2 bs-docs-sidebar">
            <ul class="nav nav-list bs-docs-sidenav">
                <li><a href="blank"><i class="icon-chevron-right"></i>首页</a></li>
                <li><a href="dormManager?action=list"><i class="icon-chevron-right"></i>宿舍管理员管理</a></li>
                <li><a href="student?action=list"><i class="icon-chevron-right"></i>学生管理</a></li>
                <li><a href="dormBuild?action=list"><i class="icon-chevron-right"></i>宿舍楼管理</a></li>
                <li><a href="record?action=list"><i class="icon-chevron-right"></i>缺勤记录</a></li>
                <li><a href="password?action=preChange"><i class="icon-chevron-right"></i>修改密码</a></li>
                <li><a href="login.jsp"><i class="icon-chevron-right"></i>退出系统</a></li>
            </ul>
        </div>
        <div class="span10">
            <jsp:include page="${mainPage==null?'admin/blank.jsp':mainPage}"></jsp:include>
        </div>
    </div>
</div>
</body>
</html>

mainManager.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" %>
<html lang="zh">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>宿舍管理系统</title>
    <link href="${pageContext.request.contextPath}/style/dorm.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/bootstrap-datetimepicker-master/css/bootstrap-datetimepicker.min.css"
          rel="stylesheet" media="screen">
    <link rel="stylesheet" type="text/css"
          href="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/dataTables.bootstra.css">
    <script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/jquery.js"></script>
    <script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/jquery.dataTables.js"></script>
    <script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/bootstrap.min.js"></script>
    <script type="text/javascript"
            src="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/dataTables.bootstrap.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js"
            charset="UTF-8"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/bootstrap-datetimepicker-master/js/locales/bootstrap-datetimepicker.fr.js"
            charset="UTF-8"></script>
    <script src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#DataTables_Table_0_wrapper .row-fluid").remove();
        });
    </script>
    <style type="text/css">
        .bs-docs-sidenav {
            background-color: #fff;
            border-radius: 6px;
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.067);
            padding: 0;
            width: 228px;
        }
        .bs-docs-sidenav > li > a {
            border: 1px solid #e5e5e5;
            display: block;
            padding: 8px 14px;
            margin: 0 0 -1px;
        }
        .bs-docs-sidenav > li:first-child > a {
            border-radius: 6px 6px 0 0;
        }
        .bs-docs-sidenav > li:last-child > a {
            border-radius: 0 0 6px 6px;
        }
        .bs-docs-sidenav > .active > a {
            border: 0 none;
            box-shadow: 1px 0 0 rgba(0, 0, 0, 0.1) inset, -1px 0 0 rgba(0, 0, 0, 0.1) inset;
            padding: 9px 15px;
            position: relative;
            text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
            z-index: 2;
        }
        .bs-docs-sidenav .icon-chevron-right {
            float: right;
            margin-right: -6px;
            margin-top: 2px;
            opacity: 0.25;
        }
        .bs-docs-sidenav > li > a:hover {
            background-color: #f5f5f5;
        }
        .bs-docs-sidenav a:hover .icon-chevron-right {
            opacity: 0.5;
        }
        .bs-docs-sidenav .active .icon-chevron-right, .bs-docs-sidenav .active a:hover .icon-chevron-right {
            background-image: url("../img/glyphicons-halflings-white.png");
            opacity: 1;
        }
    </style>
</head>
<body>
<div class="container-fluid" style="padding-right: 0px;padding-left: 0px;">
    <div region="north" style="height: 100px;background-image: url('images/bg.jpg')">
        <div align="left" style="width: 80%;height:100px ;float: left;padding-top: 40px;padding-left: 30px;"><font
                color="white" size="6">宿舍管理系统</font></div>
        <div style="padding-top: 70px;padding-right: 20px;">当前用户:&nbsp;<font color="red">${currentUser.userName }</font>
        </div>
    </div>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span2 bs-docs-sidebar">
            <ul class="nav nav-list bs-docs-sidenav">
                <li><a href="blank"><i class="icon-chevron-right"></i>首页</a></li>
                <li><a href="student?action=list"><i class="icon-chevron-right"></i>学生查看</a></li>
                <li><a href="record?action=list"><i class="icon-chevron-right"></i>缺勤记录</a></li>
                <li><a href="password?action=preChange"><i class="icon-chevron-right"></i>修改密码</a></li>
                <li><a href="login.jsp"><i class="icon-chevron-right"></i>退出系统</a></li>
            </ul>
        </div>
        <div class="span10">
            <jsp:include page="${mainPage==null?'admin/blank.jsp':mainPage}"></jsp:include>
        </div>
    </div>
</div>
</body>
</html>

mainStudent.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" %>
<html lang="zh">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>宿舍管理系统</title>
    <link href="${pageContext.request.contextPath}/style/dorm.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/bootstrap-datetimepicker-master/css/bootstrap-datetimepicker.min.css"
          rel="stylesheet" media="screen">
    <link rel="stylesheet" type="text/css"
          href="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/dataTables.bootstra.css">
    <script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/jquery.js"></script>
    <script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/jquery.dataTables.js"></script>
    <script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/bootstrap.min.js"></script>
    <script type="text/javascript"
            src="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/dataTables.bootstrap.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js"
            charset="UTF-8"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/bootstrap-datetimepicker-master/js/locales/bootstrap-datetimepicker.fr.js"
            charset="UTF-8"></script>
    <script src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#DataTables_Table_0_wrapper .row-fluid").remove();
        });
    </script>
    <style type="text/css">
        .bs-docs-sidenav {
            background-color: #fff;
            border-radius: 6px;
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.067);
            padding: 0;
            width: 228px;
        }
        .bs-docs-sidenav > li > a {
            border: 1px solid #e5e5e5;
            display: block;
            padding: 8px 14px;
            margin: 0 0 -1px;
        }
        .bs-docs-sidenav > li:first-child > a {
            border-radius: 6px 6px 0 0;
        }
        .bs-docs-sidenav > li:last-child > a {
            border-radius: 0 0 6px 6px;
        }
        .bs-docs-sidenav > .active > a {
            border: 0 none;
            box-shadow: 1px 0 0 rgba(0, 0, 0, 0.1) inset, -1px 0 0 rgba(0, 0, 0, 0.1) inset;
            padding: 9px 15px;
            position: relative;
            text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
            z-index: 2;
        }
        .bs-docs-sidenav .icon-chevron-right {
            float: right;
            margin-right: -6px;
            margin-top: 2px;
            opacity: 0.25;
        }
        .bs-docs-sidenav > li > a:hover {
            background-color: #f5f5f5;
        }
        .bs-docs-sidenav a:hover .icon-chevron-right {
            opacity: 0.5;
        }
        .bs-docs-sidenav .active .icon-chevron-right, .bs-docs-sidenav .active a:hover .icon-chevron-right {
            background-image: url("../img/glyphicons-halflings-white.png");
            opacity: 1;
        }
    </style>
</head>
<body>
<div class="container-fluid" style="padding-right: 0px;padding-left: 0px;">
    <div region="north" style="height: 100px;background-image: url('images/bg.jpg')">
        <div align="left" style="width: 80%;height:100px ;float: left;padding-top: 40px;padding-left: 30px;"><font
                color="white" size="6">宿舍管理系统</font></div>
        <div style="padding-top: 70px;padding-right: 20px;">当前用户:&nbsp;<font color="red">${currentUser.userName }</font>
        </div>
    </div>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span2 bs-docs-sidebar">
            <ul class="nav nav-list bs-docs-sidenav">
                <li><a href="blank"><i class="icon-chevron-right"></i>首页</a></li>
                <li><a href="record?action=list"><i class="icon-chevron-right"></i>缺勤记录</a></li>
                <li><a href="password?action=preChange"><i class="icon-chevron-right"></i>修改密码</a></li>
                <li><a href="login.jsp"><i class="icon-chevron-right"></i>退出系统</a></li>
            </ul>
        </div>
        <div class="span10">
            <jsp:include page="${mainPage==null?'admin/blank.jsp':mainPage}"></jsp:include>
        </div>
    </div>
</div>
</body>
</html>


四、其他


1.其他系统实现


1.JavaWeb系统系列实现


Java+JSP实现学生图书管理系统


Java+JSP实现学生信息管理系统


Java+JSP实现用户信息管理系统


Java+Servlet+JSP实现航空订票系统


Java+Servlet+JSP实现新闻发布系统


Java+Servlet+JSP实现学生信息管理系统


Java+Servlet+JSP实现学生选课管理系统


Java+Servlet+JSP实现学生成绩管理系统-1


Java+Servlet+JSP实现学生成绩管理系统-2


Java+Servlet+JSP实现宠物诊所管理系统


Java+SSM+JSP实现网上考试系统


Java+SSH+JSP实现在线考试系统


Java+Springboot+Mybatis+Bootstrap+Maven实现网上商城系统


2.JavaSwing系统系列实现


Java+Swing实现斗地主游戏


Java+Swing实现图书管理系统


Java+Swing实现医院管理系统


Java+Swing实现考试管理系统


Java+Swing实现仓库管理系统-1


Java+Swing实现仓库管理系统-2


Java+Swing实现自助取款机系统


Java+Swing实现通讯录管理系统


Java+Swing实现停车场管理系统


Java+Swing实现学生信息管理系统


Java+Swing实现学生宿舍管理系统


Java+Swing实现学生选课管理系统


Java+Swing实现学生成绩管理系统


Java+Swing实现学校教材管理系统


Java+Swing实现学校教务管理系统


Java+Swing实现企业人事管理系统


Java+Swing实现电子相册管理系统


Java+Swing实现超市管理系统-TXT存储数据


Java+Swing实现自助取款机系统-TXT存储数据


Java+Swing实现宠物商店管理系统-TXT存储数据


相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2月前
|
监控 Java API
如何使用Java语言快速开发一套智慧工地系统
使用Java开发智慧工地系统,采用Spring Cloud微服务架构和前后端分离设计,结合MySQL、MongoDB数据库及RESTful API,集成人脸识别、视频监控、设备与环境监测等功能模块,运用Spark/Flink处理大数据,ECharts/AntV G2实现数据可视化,确保系统安全与性能,采用敏捷开发模式,提供详尽文档与用户培训,支持云部署与容器化管理,快速构建高效、灵活的智慧工地解决方案。
|
1天前
|
存储 分布式计算 Hadoop
基于Java的Hadoop文件处理系统:高效分布式数据解析与存储
本文介绍了如何借鉴Hadoop的设计思想,使用Java实现其核心功能MapReduce,解决海量数据处理问题。通过类比图书馆管理系统,详细解释了Hadoop的两大组件:HDFS(分布式文件系统)和MapReduce(分布式计算模型)。具体实现了单词统计任务,并扩展支持CSV和JSON格式的数据解析。为了提升性能,引入了Combiner减少中间数据传输,以及自定义Partitioner解决数据倾斜问题。最后总结了Hadoop在大数据处理中的重要性,鼓励Java开发者学习Hadoop以拓展技术边界。
18 7
|
2月前
|
设计模式 消息中间件 搜索推荐
Java 设计模式——观察者模式:从优衣库不使用新疆棉事件看系统的动态响应
【11月更文挑战第17天】观察者模式是一种行为设计模式,定义了一对多的依赖关系,使多个观察者对象能直接监听并响应某一主题对象的状态变化。本文介绍了观察者模式的基本概念、商业系统中的应用实例,如优衣库事件中各相关方的动态响应,以及模式的优势和实际系统设计中的应用建议,包括事件驱动架构和消息队列的使用。
|
5月前
|
缓存 安全 Java
Java服务器端技术:Servlet与JSP的集成与扩展
Java服务器端技术:Servlet与JSP的集成与扩展
54 3
|
5月前
|
存储 缓存 前端开发
Servlet与JSP在Java Web应用中的性能调优策略
Servlet与JSP在Java Web应用中的性能调优策略
49 1
|
5月前
|
存储 Java 关系型数据库
基于Servlet和JSP的Java Web应用开发指南
基于Servlet和JSP的Java Web应用开发指南
129 0
|
5月前
|
前端开发 安全 Java
在Java服务器端开发的浩瀚宇宙中,Servlet与JSP犹如两颗璀璨的明星,它们联袂登场,共同编织出动态网站的绚丽篇章。
在Java服务器端开发的浩瀚宇宙中,Servlet与JSP犹如两颗璀璨的明星,它们联袂登场,共同编织出动态网站的绚丽篇章。
35 0
|
7月前
|
自然语言处理 前端开发 Java
Servlet与JSP:Java Web开发的基石技术详解
【6月更文挑战第23天】Java Web的Servlet与JSP是动态网页的核心。Servlet是服务器端的Java应用,处理HTTP请求并响应;JSP则是结合HTML与Java代码的页面,用于动态内容生成。Servlet通过生命周期方法如`init()`、`service()`和`destroy()`工作,而JSP在执行时编译成Servlet。两者在MVC架构中分工,Servlet处理逻辑,JSP展示数据。尽管有Spring MVC等框架,Servlet和JSP仍是理解Web开发基础的关键。
131 12
|
7月前
|
存储 Java 关系型数据库
基于Servlet和JSP的Java Web应用开发指南
【6月更文挑战第23天】构建Java Web应用,Servlet与JSP携手打造在线图书管理系统,涵盖需求分析、设计、编码到测试。通过实例展示了Servlet如何处理用户登录(如`LoginServlet`),JSP负责页面展示(如`login.jsp`和`bookList.jsp`)。应用基于MySQL数据库,包含用户和图书表。登录失败显示错误信息,成功后展示图书列表。部署到Tomcat服务器测试功能。此基础教程为深入Java Web开发奠定了基础。
148 10
|
7月前
|
缓存 小程序 前端开发
Java服务器端技术探秘:Servlet与JSP的核心原理
【6月更文挑战第23天】Java Web开发中的Servlet和JSP详解:Servlet是服务器端的Java小程序,处理HTTP请求并响应。生命周期含初始化、服务和销毁。创建Servlet示例代码展示了`doGet()`方法的覆盖。JSP则侧重视图,动态HTML生成,通过JSP脚本元素、声明和表达式嵌入Java代码。Servlet常作为控制器,JSP处理视图,遵循MVC模式。优化策略涉及缓存、分页和安全措施。这些技术是Java服务器端开发的基础。
76 9