基于javaweb+jsp的银行信息管理系统

基于javaweb+jsp的银行信息管理系统

JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap

基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可

开发工具:eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

        }
    }

    //@Override
    public void update(Chuhu vo) {
        String sql = "update `t_chuhu` set `chuhu_no` = ? ,`chuhu_pass` = ? ,`chuhu_date` = ? ,`chuhu_yue` = ? ,`chuhu_name` = ? ,`chuhu_sex` = ? ,`chuhu_idno` = ? ,`chuhu_phone` = ? ,`chuhu_address` = ? ,`chuhu_text` = ?  where `id` = ?";
        try {
            Connection c = Util.getConnection();
            PreparedStatement ps = c.prepareStatement(sql);
            
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>员工编辑title>
    <%@ include file="include/head.jsp" %>
head>
<body>
<div class="container-fluid">
    <ul class="nav nav-tabs">
        <li><a href="EmpServlet?action=list">员工列表a>li>
        <li class="active"><a href="#">编辑a>li>
    ul>
/**
 * 储户模块的DAO层(数据层)的具体实现类,对ChuhuDAO接口中定义的增删改查等抽象方法作出具体的功能实现
 */
public class ChuhuDAOImpl implements ChuhuDAO {

    //@Override
    public void add(Chuhu vo) {
        String sql = "insert into `t_chuhu` (`chuhu_no`,`chuhu_pass`,`chuhu_date`,`chuhu_yue`,`chuhu_name`,`chuhu_sex`,`chuhu_idno`,`chuhu_phone`,`chuhu_address`,`chuhu_text`) values(?,?,?,?,?,?,?,?,?,?)";
        try {
            Connection c = Util.getConnection();
            PreparedStatement ps = c.prepareStatement(sql);
            
            ps.setString(1, vo.getChuhuNo());
            ps.setString(2, vo.getChuhuPass());
            ps.setString(3, vo.getChuhuDate());
            ps.setString(4, vo.getChuhuYue());
            ps.setString(5, vo.getChuhuName());
        }
    }

    //@Override
    public Chuhu get(Serializable id) {
        Chuhu vo = null;
        try {
            Connection c = Util.getConnection();
            Statement s = c.createStatement();
            String sql = "select * from `t_chuhu` where id = " + id;
            ResultSet rs = s.executeQuery(sql);
        } else {//默认去列表页面
            this.redirectList(request, response);
        }
    }

    /**
     * 处理Get请求
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    @Override
                || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
                || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS);
    }

    /**
     * 判断字符串是否是乱码
     *
     * @param strName
     * @return
     */
    public static boolean isMessyCode(String strName) {
        java.util.regex.Pattern p = java.util.regex.Pattern.compile("\\s*|\t*|\r*|\n*");
        java.util.regex.Matcher m = p.matcher(strName);
        String after = m.replaceAll("");
        String temp = after.replaceAll("\\p{P}", "");
        char[] ch = temp.trim().toCharArray();
        float chLength = 0;
        float count = 0;
        for (int i = 0; i < ch.length; i++) {
        if (document.getElementById("chuhuPass").value.trim().length == 0) {
            alert("密码不能为空!");
            return false;
        }
        if (document.getElementById("chuhuDate").value.trim().length == 0) {
            alert("开户日期不能为空!");
            return false;
        }
        if (document.getElementById("chuhuYue").value.trim().length == 0) {
            alert("帐户余额不能为空!");
            return false;
        }
        if (document.getElementById("chuhuName").value.trim().length == 0) {
            alert("姓名不能为空!");
            return false;
        }
        if (document.getElementById("chuhuIdno").value.trim().length == 0) {
            alert("身份证不能为空!");
            return false;
        }
        if (document.getElementById("chuhuPhone").value.trim().length == 0) {
            alert("联系方式不能为空!");
     */
    public static boolean isMessyCode(String strName) {
        java.util.regex.Pattern p = java.util.regex.Pattern.compile("\\s*|\t*|\r*|\n*");
        java.util.regex.Matcher m = p.matcher(strName);
        String after = m.replaceAll("");
        String temp = after.replaceAll("\\p{P}", "");
        char[] ch = temp.trim().toCharArray();
        float chLength = 0;
        float count = 0;
        for (int i = 0; i < ch.length; i++) {
            char c = ch[i];
            if (!Character.isLetterOrDigit(c)) {
                if (!isChinese(c)) {
                    count = count + 1;
                }
                chLength++;
            ps.setString(1, vo.getNoticeName());
            ps.setString(2, vo.getNoticeText());
            ps.setString(3, vo.getNoticeType());
            ps.setString(4, vo.getCreateDate());
            ps.setLong(5, vo.getId());
            ps.execute();
            ps.close();
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //@Override
        } else if ("edit".equals(action)) {//修改
            //取出页面传进来的各个数据,并设置到Notice对象的属性里
            Notice vo = new Notice();
            vo.setId(Long.valueOf(Util.decode(request, "id")));
            vo.setNoticeName(Util.decode(request, "noticeName"));
            vo.setNoticeText(Util.decode(request, "noticeText"));
            vo.setNoticeType(Util.decode(request, "noticeType"));
            vo.setCreateDate(Util.decode(request, "createDate"));
            NoticeService noticeService = new NoticeServiceImpl();
            //调用Service层更新方法(update),更新记录
            noticeService.update(vo);
            this.redirectList(request, response);
        } else if ("get".equalsIgnoreCase(action) || "editPre".equalsIgnoreCase(action)) {//根据主键ID,查询详情信息并跳转到详情页面或编辑页面
            Serializable id = Util.decode(request, "id");//取出页面传入的主键,用于查询详情
            NoticeService noticeService = new NoticeServiceImpl();
            Notice vo = noticeService.get(id);
            request.getSession().setAttribute("vo", vo);
            String to = "get".equalsIgnoreCase(action) ? "info" : "edit";//判断是去详情显示页面还是编辑页面
            condition += " and `" + params.get("searchColumn") + "` like '%" + params.get("keyword") + "%'";
        }
        try {
            Connection c = Util.getConnection();
            PreparedStatement ps;
            ResultSet rs;
            String limit = (params.get("startIndex") != null && params.get("pageSize") != null) ? " limit " + params.get("startIndex") + "," + params.get("pageSize") : "";
                sqlList = "select * from `t_emp` where 1=1 " + condition + " order by id asc " + limit + ";";
                ps = c.prepareStatement(sqlList);
                rs = ps.executeQuery();
            ps.setString(1, vo.getEmpNo());
            ps.setString(2, vo.getEmpName());
            ps.setString(3, vo.getEmpSex());
            ps.setString(4, vo.getEmpPhone());
            ps.setString(5, vo.getEmpZhiwei());
            ps.setString(6, vo.getEmpText());
            ps.execute();
            ps.close();
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //@Override
    public void update(Emp vo) {
        String sql = "update `t_emp` set `emp_no` = ? ,`emp_name` = ? ,`emp_sex` = ? ,`emp_phone` = ? ,`emp_zhiwei` = ? ,`emp_text` = ?  where `id` = ?";
        try {
            Connection c = Util.getConnection();
            PreparedStatement ps = c.prepareStatement(sql);
                <input type="text" class="form-control" id="chuhuName" name="chuhuName">
            div>
        div>
        <div class="form-group">
            <label class="col-sm-3 control-label">性别:label>
            <div class="col-sm-5">
                <input name="chuhuSex" type="radio" value="" checked="checked"/>       
                <input name="chuhuSex" type="radio" value=""/>       
            div>
        div>
        <div class="form-group">
            <label class="col-sm-3 control-label">身份证:label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="chuhuIdno" name="chuhuIdno">
            div>
        div>
        <div class="form-group">
            <label class="col-sm-3 control-label">联系方式:label>
            <div class="col-sm-5">
//@WebServlet("/UserServlet")
public class UserServlet extends HttpServlet {

    /**
     * 处理Post请求
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //过滤编码
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String action = Util.decode(request, "action");
        if ("add".equals(action)) {//增加
            User vo = new User();
            //取出页面传进来的各个数据,并设置到User对象的属性里
            vo.setUsername(Util.decode(request, "username"));
            vo.setPassword(Util.decode(request, "password"));
            vo.setRealName(Util.decode(request, "realName"));
            vo.setUserSex(Util.decode(request, "userSex"));
                rs = ps.executeQuery();
                while (rs.next()) {
                    User vo = new User();
                    vo.setId(rs.getLong("id"));
                    vo.setUsername(rs.getString("username"));
                    vo.setPassword(rs.getString("password"));
                    vo.setRealName(rs.getString("real_name"));
                    vo.setUserSex(rs.getString("user_sex"));
                    vo.setUserPhone(rs.getString("user_phone"));
                    vo.setUserText(rs.getString("user_text"));
                    vo.setUserType(rs.getString("user_type"));
                    list.add(vo);
                }
            String sqlCount = "select count(*) from `t_user` where 1=1 " + condition;
            ps = c.prepareStatement(sqlCount);
            rs = ps.executeQuery();
            if (rs.next()) {
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    // 返回一个随机颜色(Color对象)
    private Color getRandomColor(int minColor, int maxColor) {
        Random random = new Random();
        // 保存minColor最大不会超过255
        if (minColor > 255)
            minColor = 255;
        //  保存minColor最大不会超过255
        if (maxColor > 255)
            maxColor = 255;
        //  获得红色的随机颜色值
        int red = minColor + random.nextInt(maxColor - minColor);
            }
            request.getSession().setAttribute("alert_msg", msg);
            request.getRequestDispatcher("reset_password.jsp").forward(request, response);
        } else {
            response.sendRedirect("login.jsp");
        }
    }

    /**
     * 处理Get请求
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

     * 取得数据库连接对象
     *
     * @return 如果连接成功则返回连接对象,如果连接失败返回null
     */
    public static Connection getConnection() throws Exception {
        Class.forName(DBDRIVER);
        return DriverManager.getConnection(DBURL, DBUSER, PASSWORD);
    }
    /**
     * 测试连接是否成功
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("notice_list.jsp");
    }
}
package com.demo.dao.impl;

import com.demo.util.Util;
import com.demo.dao.UserDAO;
import com.demo.vo.User;

import java.io.Serializable;
import java.sql.Connection;
    // 返回一个随机颜色(Color对象)
    private Color getRandomColor(int minColor, int maxColor) {
        Random random = new Random();
        // 保存minColor最大不会超过255
        if (minColor > 255)
            minColor = 255;
        //  保存minColor最大不会超过255
        if (maxColor > 255)
            maxColor = 255;
        //  获得红色的随机颜色值
        int red = minColor + random.nextInt(maxColor - minColor);
        //  获得绿色的随机颜色值
            alert("密码不能为空!");
            return false;
        }
        if (document.getElementById("realName").value.trim().length == 0) {
            alert("姓名不能为空!");
            return false;
        }
        if (document.getElementById("userPhone").value.trim().length == 0) {
            alert("手机不能为空!");
            return false;
        }
        return true;
    }
script>
html>
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>用户添加title>
    <%@ include file="include/head.jsp" %>
head>
<body>
<div class="container-fluid">

    /**
     * 处理Get请求
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);//Get请求和Post请求的处理是一样的,所以把request、response转交给Post方法就好
    }

    /**
     * 根据参数,查询出条例条件的记录集合,最后将数据返回给调用处或者将数据集合设置到session域里,再跳转到对应的列表页面
            return false;
        }
        if (document.getElementById("password").value.trim().length == 0) {
            alert("密码不能为空!");
            return false;
        }
        if (document.getElementById("realName").value.trim().length == 0) {
            alert("姓名不能为空!");
            return false;
        }
        if (document.getElementById("userPhone").value.trim().length == 0) {
            alert("手机不能为空!");
            return false;
        }
                str = new String(str.getBytes("GBK"), "ISO-8859-1");
            }
            if (isMessyCode(str)) {
                str = new String(str.getBytes("UTF-8"), "GB2312");
            }
            if (isMessyCode(str)) {
                str = new String(str.getBytes("ISO-8859-1"), "GB2312");
            }
            if (isMessyCode(str)) {
                str = new String(str.getBytes("GBK"), "GB2312");
            }
            if (isMessyCode(str)) {
                str = new String(str.getBytes("UTF-8"), "GBK");
            }
            if (isMessyCode(str)) {
                str = new String(str.getBytes("ISO-8859-1"), "GBK");
            }
            if (isMessyCode(str)) {
                str = new String(str.getBytes("GB2312"), "GBK");
            }
        } catch (Exception e) {
    /**
     * 判断字符串是不是中文
     *
     * @param c
     * @return
     */
    private static boolean isChinese(char c) {
        Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
        return (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
                || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
                || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
                || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
                || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
                || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS);
    }

        try {
            Connection c = Util.getConnection();
            PreparedStatement ps = c.prepareStatement(sql);
            
            ps.setString(1, vo.getChuhuNo());
            ps.setString(2, vo.getChuhuPass());
            ps.setString(3, vo.getChuhuDate());
            ps.setString(4, vo.getChuhuYue());
            ps.setString(5, vo.getChuhuName());
            ps.setString(6, vo.getChuhuSex());
            ps.setString(7, vo.getChuhuIdno());
            ps.setString(8, vo.getChuhuPhone());
            ps.setString(9, vo.getChuhuAddress());
            ps.setString(10, vo.getChuhuText());
            ps.setLong(11, vo.getId());
            ps.execute();
            ps.close();
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

        Map<String, Object> result = new HashMap();
        result.put("list", list);
        result.put("totalCount", totalCount);
        return result;
    }
}
package com.demo.dao.impl;

import com.demo.util.Util;
import com.demo.dao.EmpDAO;
import com.demo.vo.Emp;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;

运行环境

Java≥6、Tomcat≥7.0、MySQL≥5.5

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

技术框架

JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap

基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

登录、注册、退出、用户模块、公告模块、员工模块、储户模块的增删改查管理

基于javaweb+jsp的银行信息管理系统_第1张图片

基于javaweb+jsp的银行信息管理系统_第2张图片

基于javaweb+jsp的银行信息管理系统_第3张图片

基于javaweb+jsp的银行信息管理系统_第4张图片

基于javaweb+jsp的银行信息管理系统_第5张图片

基于javaweb+jsp的银行信息管理系统_第6张图片

基于javaweb+jsp的银行信息管理系统_第7张图片

基于javaweb+jsp的银行信息管理系统_第8张图片

基于javaweb+jsp的银行信息管理系统_第9张图片

基于javaweb+jsp的银行信息管理系统_第10张图片

基于javaweb+jsp的银行信息管理系统_第11张图片

基于javaweb+jsp的银行信息管理系统_第12张图片

基于javaweb+jsp的银行信息管理系统_第13张图片

基于javaweb+jsp的银行信息管理系统_第14张图片

↖[获取源码方式]见左侧

你可能感兴趣的:(javaweb,jsp,mysql,servlet,ssm)