0
点赞
收藏
分享

微信扫一扫

基于javaweb+jsp的银行信息管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Bootstrap)

i奇异 2022-04-13 阅读 84
javamysql

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等均可配置运行

适用

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

            <div class="form-group">
                <label class="col-sm-3 control-label">姓名:</label>
                <div class="col-sm-5">
                    <input type="text" class="form-control" id="realName" name="realName" value="${vo.realName}">
                </div>
            </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">性别:</label>
            <div class="col-sm-5">
                       <input name="userSex" type="radio" value="男" ${vo.userSex=='男'?'checked':''}/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                       <input name="userSex" type="radio" value="女" ${vo.userSex=='女'?'checked':''}/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </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="userPhone" name="userPhone" value="${vo.userPhone}">
                </div>
            </div>
        <div class="form-group">
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    //@Override
    public Emp get(Serializable id) {
        Emp vo = null;
        try {
            Connection c = Util.getConnection();
            Statement s = c.createStatement();
            String sql = "select * from `t_emp` where id = " + id;
            ResultSet rs = s.executeQuery(sql);
            if (rs.next()) {
                vo = new Emp();
                vo.setId(rs.getLong("id"));
                vo.setEmpNo(rs.getString("emp_no"));
                vo.setEmpName(rs.getString("emp_name"));
     *
     * @return
     */
    public static String getTime() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis());
    }
    /**
     * 判断字符串是不是中文
     *
     * @param c
     * @return
     */
    private static boolean isChinese(char c) {
        Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
        return (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
     * @throws IOException
     */
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);//Get请求和Post请求的处理是一样的,所以把request、response转交给Post方法就好
    }

    /**
     * 根据参数,查询出条例条件的记录集合,最后将数据返回给调用处或者将数据集合设置到session域里,再跳转到对应的列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = Util.decode(request, "searchColumn");
        String keyword = Util.decode(request, "keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword);//查询的关键字
        NoticeService noticeService = new NoticeServiceImpl();
        Map<String, Object> map = noticeService.list(params);
            if (rs.next()) {
                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"));
            }
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return vo;
    }

    //@Override
    public Map<String, Object> list(Map<String, Object> params) {
        List<User> list = new ArrayList();
        int totalCount = 0;
        String condition = "";
        String sqlList;
        if (params.get("searchColumn") != null && !"".equals(params.get("searchColumn"))) {
            c.close();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    //@Override
    public Notice get(Serializable id) {
        Notice vo = null;
        try {
            Connection c = Util.getConnection();
            Statement s = c.createStatement();
            String sql = "select * from `t_notice` where id = " + id;
            ResultSet rs = s.executeQuery(sql);
            vo.setChuhuAddress(Util.decode(request, "chuhuAddress"));
            vo.setChuhuText(Util.decode(request, "chuhuText"));
            ChuhuService chuhuService = new ChuhuServiceImpl();
            //调用Service层增加方法(add),增加记录
            chuhuService.add(vo);
            this.redirectList(request, response);
        } else if ("delete".equals(action)) {//删除
            //取出表要删除的储户记录的主键
            long id = Long.parseLong(Util.decode(request, "id"));
            ChuhuService chuhuService = new ChuhuServiceImpl();
            //调用Service层删除方法(delete),将对应的记录删除
            chuhuService.delete(id);
            this.redirectList(request, response);
        } else if ("edit".equals(action)) {//修改
            //取出页面传进来的各个数据,并设置到Chuhu对象的属性里
            Chuhu vo = new Chuhu();
            vo.setId(Long.valueOf(Util.decode(request, "id")));
            vo.setChuhuNo(Util.decode(request, "chuhuNo"));
            vo.setChuhuPass(Util.decode(request, "chuhuPass"));
            vo.setChuhuDate(Util.decode(request, "chuhuDate"));
            vo.setChuhuYue(Util.decode(request, "chuhuYue"));
            vo.setChuhuName(Util.decode(request, "chuhuName"));
            vo.setChuhuSex(Util.decode(request, "chuhuSex"));
            vo.setChuhuIdno(Util.decode(request, "chuhuIdno"));
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("emp_list.jsp");
    }
}
package com.demo.servlet;

import com.demo.util.Util;
import com.demo.service.NoticeService;
import com.demo.service.impl.NoticeServiceImpl;
import com.demo.vo.Notice;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 公告模块的Servlet控制层,负责接收页面传过来的请求参数,根据action参数的值来确定页面要执行的具体操作<br>
     * @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)) {//增加
            Notice vo = new Notice();
            //取出页面传进来的各个数据,并设置到Notice对象的属性里
            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层增加方法(add),增加记录
            noticeService.add(vo);
            this.redirectList(request, response);
        } else if ("delete".equals(action)) {//删除
            //取出表要删除的公告记录的主键
            long id = Long.parseLong(Util.decode(request, "id"));
            NoticeService noticeService = new NoticeServiceImpl();
            //调用Service层删除方法(delete),将对应的记录删除
            noticeService.delete(id);
//@WebServlet("/EmpServlet")
public class EmpServlet 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)) {//增加
            Emp vo = new Emp();
            //取出页面传进来的各个数据,并设置到Emp对象的属性里
            vo.setEmpNo(Util.decode(request, "empNo"));
            vo.setEmpName(Util.decode(request, "empName"));
            vo.setEmpSex(Util.decode(request, "empSex"));
            vo.setEmpPhone(Util.decode(request, "empPhone"));
                <label class="col-sm-3 control-label">联系方式:</label>
                <div class="col-sm-5">
                    <input type="text" class="form-control" id="empPhone" name="empPhone" value="${vo.empPhone}">
                </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="empZhiwei" name="empZhiwei" value="${vo.empZhiwei}">
                </div>
            </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注:</label>
            <div class="col-sm-5">
                <textarea rows="3" class="form-control" id="empText" name="empText" placeholder="请输入内容......">${vo.empText}</textarea>
            </div>
        </div>
        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = Util.decode(request, "pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) empService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("EmpServlet");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("emp_list.jsp");
    }
}
package com.demo.servlet;

import com.demo.util.Util;
import com.demo.service.NoticeService;
import com.demo.service.impl.NoticeServiceImpl;
import com.demo.vo.Notice;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
            PreparedStatement ps = c.prepareStatement(sql);
            
            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
    public boolean delete(long id) {
        try {
            Connection c = Util.getConnection();
            Statement s = c.createStatement();
            String sql = "delete from `t_notice` where id = " + id;
            s.execute(sql);
            s.close();
            c.close();
            return true;
        } catch (Exception e) {
     */
    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++;
            }
        }
        return count / chLength > 0.4;
    }

            vo.setChuhuPhone(Util.decode(request, "chuhuPhone"));
            vo.setChuhuAddress(Util.decode(request, "chuhuAddress"));
            vo.setChuhuText(Util.decode(request, "chuhuText"));
            ChuhuService chuhuService = new ChuhuServiceImpl();
            //调用Service层更新方法(update),更新记录
            chuhuService.update(vo);
            this.redirectList(request, response);
        } else if ("get".equalsIgnoreCase(action) || "editPre".equalsIgnoreCase(action)) {//根据主键ID,查询详情信息并跳转到详情页面或编辑页面
            Serializable id = Util.decode(request, "id");//取出页面传入的主键,用于查询详情
            ChuhuService chuhuService = new ChuhuServiceImpl();
            Chuhu vo = chuhuService.get(id);
            request.getSession().setAttribute("vo", vo);
            String to = "get".equalsIgnoreCase(action) ? "info" : "edit";//判断是去详情显示页面还是编辑页面
            response.sendRedirect("chuhu_" + to + ".jsp");
        } else {//默认去列表页面
            this.redirectList(request, response);
        }
    }

    /**
     * 处理Get请求
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    @Override
        </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="chuhuDate" name="chuhuDate">
            </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="chuhuYue" name="chuhuYue">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">姓名:</label>
            <div class="col-sm-5">
            <label class="col-sm-3 control-label">性别:</label>
            <div class="col-sm-5">
                       <input name="userSex" type="radio" value="男" ${vo.userSex=='男'?'checked':''}/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                       <input name="userSex" type="radio" value="女" ${vo.userSex=='女'?'checked':''}/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </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="userPhone" name="userPhone" value="${vo.userPhone}">
                </div>
            </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注:</label>
            <div class="col-sm-5">
                <textarea rows="3" class="form-control" id="userText" name="userText" placeholder="请输入内容......">${vo.userText}</textarea>
     *
     * @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)) {//增加
            Notice vo = new Notice();
            //取出页面传进来的各个数据,并设置到Notice对象的属性里
            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层增加方法(add),增加记录
            noticeService.add(vo);
            this.redirectList(request, response);
        } else if ("delete".equals(action)) {//删除
            //取出表要删除的公告记录的主键
            long id = Long.parseLong(Util.decode(request, "id"));
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    //@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);
            if (rs.next()) {
                vo = new Chuhu();
                vo.setId(rs.getLong("id"));
                vo.setChuhuNo(rs.getString("chuhu_no"));
                vo.setChuhuPass(rs.getString("chuhu_pass"));
                vo.setChuhuDate(rs.getString("chuhu_date"));
        }
        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("联系方式不能为空!");
            return false;
        }
        if (document.getElementById("chuhuAddress").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>
            vo.setChuhuYue(Util.decode(request, "chuhuYue"));
            vo.setChuhuName(Util.decode(request, "chuhuName"));
            vo.setChuhuSex(Util.decode(request, "chuhuSex"));
            vo.setChuhuIdno(Util.decode(request, "chuhuIdno"));
            vo.setChuhuPhone(Util.decode(request, "chuhuPhone"));
            vo.setChuhuAddress(Util.decode(request, "chuhuAddress"));
            vo.setChuhuText(Util.decode(request, "chuhuText"));
            ChuhuService chuhuService = new ChuhuServiceImpl();
            //调用Service层更新方法(update),更新记录
            chuhuService.update(vo);
            this.redirectList(request, response);
        } else if ("get".equalsIgnoreCase(action) || "editPre".equalsIgnoreCase(action)) {//根据主键ID,查询详情信息并跳转到详情页面或编辑页面
            Serializable id = Util.decode(request, "id");//取出页面传入的主键,用于查询详情
            ChuhuService chuhuService = new ChuhuServiceImpl();
            Chuhu vo = chuhuService.get(id);
            request.getSession().setAttribute("vo", vo);
            String to = "get".equalsIgnoreCase(action) ? "info" : "edit";//判断是去详情显示页面还是编辑页面
            response.sendRedirect("chuhu_" + to + ".jsp");
        } else {//默认去列表页面
            this.redirectList(request, response);
        }
    }

    /**

运行环境

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…均可

适用

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

功能说明

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

20220319003552

20220319003553

20220319003554

20220319003555

20220319003556

20220319003557

20220319003558

20220319003559

20220319003600

20220319003601

20220319003602

20220319003603

20220319003604

document

举报

相关推荐

0 条评论