0
点赞
收藏
分享

微信扫一扫

基于javaweb+jsp的快递物流管理系统

悬灸人雪洋 2022-03-27 阅读 37

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 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
                    <input type="text" class="form-control" id="orderJiphone" name="orderJiphone" value="${vo.orderJiphone}">
                </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="orderJiaddress" name="orderJiaddress" value="${vo.orderJiaddress}">
                </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="orderCarno" name="orderCarno" value="${vo.orderCarno}">
                </div>
            </div>
        String condition = "";
        String sqlList;
        if (params.get("searchColumn") != null && !"".equals(params.get("searchColumn"))) {
            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") : "";
        int totalCount = 0;
        String condition = "";
        String sqlList;
        if (params.get("searchColumn") != null && !"".equals(params.get("searchColumn"))) {
            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_notice` where 1=1 " + condition + " order by id asc " + limit + ";";
                ps = c.prepareStatement(sqlList);
                rs = ps.executeQuery();
                while (rs.next()) {
                    Notice vo = new Notice();
                    vo.setId(rs.getLong("id"));
                    vo.setNoticeName(rs.getString("notice_name"));
                    vo.setNoticeText(rs.getString("notice_text"));
                    vo.setNoticeType(rs.getString("notice_type"));
                    vo.setCreateDate(rs.getString("create_date"));
        String action = Util.decode(request, "action");
        if ("add".equals(action)) {//增加
            Order vo = new Order();
            //取出页面传进来的各个数据,并设置到Order对象的属性里
            vo.setOrderName(Util.decode(request, "orderName"));
            vo.setOrderPhone(Util.decode(request, "orderPhone"));
            vo.setOrderAddress(Util.decode(request, "orderAddress"));
            vo.setOrderJiren(Util.decode(request, "orderJiren"));
            vo.setOrderJiphone(Util.decode(request, "orderJiphone"));
            vo.setOrderJiaddress(Util.decode(request, "orderJiaddress"));
            vo.setOrderCarno(Util.decode(request, "orderCarno"));
            vo.setOrderStatus(Util.decode(request, "orderStatus"));
            vo.setOrderDate(Util.decode(request, "orderDate"));
            vo.setOrderText(Util.decode(request, "orderText"));
            OrderService orderService = new OrderServiceImpl();
            //调用Service层增加方法(add),增加记录
            orderService.add(vo);
            this.redirectList(request, response);
        } else if ("delete".equals(action)) {//删除
            //取出表要删除的订单记录的主键
            long id = Long.parseLong(Util.decode(request, "id"));
                <input type="text" class="form-control" id="orderJiphone" name="orderJiphone">
            </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="orderJiaddress" name="orderJiaddress">
            </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="orderCarno" name="orderCarno">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态:</label>
            <div class="col-sm-5">
</head>
<body>
<div class="bg"></div>
<div class="container">
    <div class="line bouncein">
        <div class="xs6 xm4 xs3-move xm4-move">
            <div style="height:150px;"></div>
            <div class="media media-y margin-big-bottom">
            </div>
            <form action="AuthServlet?action=login" method="post" onsubmit="return check()">
                <div class="panel loginbox">
                    <div class="text-center margin-big padding-big-top" style="font-size: 35px;font-weight: 700;color:#000000;text-shadow: 2px 3px #FFFFFF;">快递物流管理系统</div>
                    <a style="font-size: 24px;color: #269abc;text-decoration: none;padding-left: 140px;">登录</a>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<a href="register.jsp" style="font-size: 24px;color:black ;text-decoration: none;">注册</a>
                    <div class="panel-body" style="padding:30px; padding-bottom:10px; padding-top:10px;">
                        <div class="form-group">
                            <div class="field field-icon-right">
        try {
            Connection c = Util.getConnection();
            Statement s = c.createStatement();
            String sql = "select * from `t_notice` where id = " + id;
            ResultSet rs = s.executeQuery(sql);
            if (rs.next()) {
                vo = new Notice();
                vo.setId(rs.getLong("id"));
                vo.setNoticeName(rs.getString("notice_name"));
                vo.setNoticeText(rs.getString("notice_text"));
                vo.setNoticeType(rs.getString("notice_type"));
                vo.setCreateDate(rs.getString("create_date"));
            }
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
            vo.setCarStatus(Util.decode(request, "carStatus"));
            vo.setCarText(Util.decode(request, "carText"));
            CarService carService = new CarServiceImpl();
            //调用Service层更新方法(update),更新记录
            carService.update(vo);
            this.redirectList(request, response);
        } else if ("get".equalsIgnoreCase(action) || "editPre".equalsIgnoreCase(action)) {//根据主键ID,查询详情信息并跳转到详情页面或编辑页面
            Serializable id = Util.decode(request, "id");//取出页面传入的主键,用于查询详情
            CarService carService = new CarServiceImpl();
            Car vo = carService.get(id);
            request.getSession().setAttribute("vo", vo);
            String to = "get".equalsIgnoreCase(action) ? "info" : "edit";//判断是去详情显示页面还是编辑页面
            response.sendRedirect("car_" + to + ".jsp");
        } else {//默认去列表页面
            this.redirectList(request, response);
    <%@ include file="include/head.jsp" %>
</head>
<body>
<div class="container-fluid">
    <ul class="nav nav-tabs">
        <li><a href="UserServlet?action=list">用户列表</a></li>
        <li class="active"><a href="#">添加</a></li>
    </ul>
    <br/>
    <form class="form-horizontal" role="form" action="UserServlet?action=add" method="post" onsubmit="return check()">
        <div class="form-group">
            <label class="col-sm-3 control-label">用户名:</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="username" name="username">
            </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="password" name="password">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">姓名:</label>
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword);//查询的关键字
        OrderService orderService = new OrderServiceImpl();
        Map<String, Object> map = orderService.list(params);
        request.getSession().setAttribute("list", map.get("list"));

        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) orderService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("OrderServlet");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
    <ul class="nav nav-tabs">
        <li><a href="UserServlet?action=list">用户列表</a></li>
        <li class="active"><a href="#">编辑</a></li>
    </ul>
    <br/>
    <form class="form-horizontal" role="form" action="UserServlet?action=edit" method="post" onsubmit="return check()">
        <input type="hidden" class="form-control" id="id" name="id" value="${vo.id}"/>
        
            <div class="form-group">
                <label class="col-sm-3 control-label">用户名:</label>
                <div class="col-sm-5">
                    <input type="text" class="form-control" id="username" name="username" value="${vo.username}">
                </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="password" name="password" value="${vo.password}">
                </div>
                g.setFont(new Font(fontNames[random.nextInt(3)], Font.ITALIC, height));
                //  随机获得当前验证码的字符
                char codeChar = codeChars.charAt(random.nextInt(charsLength));
                validationCode.append(codeChar);
                //  随机设置当前验证码字符的颜色
                g.setColor(getRandomColor(10, 100));
                //  在图形上输出验证码字符,x和y都是随机生成的
                g.drawString(String.valueOf(codeChar), 16 * i + random.nextInt(7), height - random.nextInt(6));
            }
            HttpSession session = request.getSession();
            session.setMaxInactiveInterval(5 * 60);
            //  将验证码保存在session对象中,key为validation_code
            session.setAttribute("validationCode", validationCode.toString());
            g.dispose();//  关闭Graphics对象
            OutputStream os = response.getOutputStream();
            ImageIO.write(image, "JPEG", os);// 以JPEG格式向客户端发送图形验证码
        } else if ("resetPassword".equalsIgnoreCase(action)) {
            String msg;
            User loginUser = (User) request.getSession().getAttribute("loginUser");
            String oldPassword = Util.decode(request, "oldPassword");
            if (!loginUser.getPassword().equals(oldPassword)) {
                msg = "原密码错误!";
            } else {
        } catch (Exception e) {
            e.printStackTrace();
        }
        return vo;
    }

    //@Override
    public Map<String, Object> list(Map<String, Object> params) {
        List<Notice> list = new ArrayList();
        int totalCount = 0;
        String condition = "";
        String sqlList;
        if (params.get("searchColumn") != null && !"".equals(params.get("searchColumn"))) {
            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_notice` where 1=1 " + condition + " order by id asc " + limit + ";";
import com.demo.service.CarService;
import com.demo.service.impl.CarServiceImpl;
import com.demo.vo.Car;
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;

/**
 * Car模块的Servlet控制层,负责接收页面传过来的请求参数,根据action参数的值来确定页面要执行的具体操作<br>
 * 而后再调用CarService业务层的方法来处理具体的业务,最后将处理完成的结果返回或跳转至相应页面
 */
//@WebServlet("/CarServlet")
public class CarServlet extends HttpServlet {

    /**
        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"));
            vo.setUserPhone(Util.decode(request, "userPhone"));
            vo.setUserText(Util.decode(request, "userText"));
            vo.setUserType(Util.decode(request, "userType"));
            UserService userService = new UserServiceImpl();
            //调用Service层增加方法(add),增加记录
            userService.add(vo);
            this.redirectList(request, response);
        } else if ("delete".equals(action)) {//删除
            //取出表要删除的用户记录的主键
            long id = Long.parseLong(Util.decode(request, "id"));
            UserService userService = new UserServiceImpl();
            //调用Service层删除方法(delete),将对应的记录删除
            userService.delete(id);
            this.redirectList(request, response);
            String limit = (params.get("startIndex") != null && params.get("pageSize") != null) ? " limit " + params.get("startIndex") + "," + params.get("pageSize") : "";
                sqlList = "select * from `t_car` where 1=1 " + condition + " order by id asc " + limit + ";";
                ps = c.prepareStatement(sqlList);
                rs = ps.executeQuery();
                while (rs.next()) {
                    Car vo = new Car();
                    vo.setId(rs.getLong("id"));
                    vo.setCarName(rs.getString("car_name"));
                    vo.setCarSiji(rs.getString("car_siji"));
                    vo.setCarPhone(rs.getString("car_phone"));
                    vo.setCarStatus(rs.getString("car_status"));
                    vo.setCarText(rs.getString("car_text"));
                    list.add(vo);
                }
            String sqlCount = "select count(*) from `t_car` where 1=1 " + condition;
            ps = c.prepareStatement(sqlCount);
            rs = ps.executeQuery();
            if (rs.next()) {
            response.sendRedirect("order_" + to + ".jsp");
        } else {//默认去列表页面
            this.redirectList(request, response);
        }
    }

    /**
     * 处理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域里,再跳转到对应的列表页面
                <div class="col-sm-5">
                    <input type="text" class="form-control" id="orderPhone" name="orderPhone" value="${vo.orderPhone}">
                </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="orderAddress" name="orderAddress" value="${vo.orderAddress}">
                </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="orderJiren" name="orderJiren" value="${vo.orderJiren}">
                </div>
            </div>
            <div class="form-group">
            ps.close();
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //@Override
    public void update(Notice vo) {
        String sql = "update `t_notice` set `notice_name` = ? ,`notice_text` = ? ,`notice_type` = ? ,`create_date` = ?  where `id` = ?";
        try {
    //@Override
    public Map<String, Object> list(Map<String, Object> params) {
        List<Notice> list = new ArrayList();
        int totalCount = 0;
        String condition = "";
        String sqlList;
        if (params.get("searchColumn") != null && !"".equals(params.get("searchColumn"))) {
            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_notice` where 1=1 " + condition + " order by id asc " + limit + ";";
                ps = c.prepareStatement(sqlList);
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Car模块的DAO层(数据层)的具体实现类,对CarDAO接口中定义的增删改查等抽象方法作出具体的功能实现
 */
public class CarDAOImpl implements CarDAO {

    //@Override
    public void add(Car vo) {
        String sql = "insert into `t_car` (`car_name`,`car_siji`,`car_phone`,`car_status`,`car_text`) values(?,?,?,?,?)";
        try {
            Connection c = Util.getConnection();
public class NoticeDAOImpl implements NoticeDAO {

    //@Override
    public void add(Notice vo) {
        String sql = "insert into `t_notice` (`notice_name`,`notice_text`,`notice_type`,`create_date`) values(?,?,?,?)";
        try {
            Connection c = Util.getConnection();
            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.execute();
            ps.close();
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //@Override
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;

/**
 * User模块的Servlet控制层,负责接收页面传过来的请求参数,根据action参数的值来确定页面要执行的具体操作<br>
 * 而后再调用UserService业务层的方法来处理具体的业务,最后将处理完成的结果返回或跳转至相应页面
 */
//@WebServlet("/UserServlet")
            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">
    <ul class="nav nav-tabs">
        <li><a href="UserServlet?action=list">用户列表</a></li>
        <li class="active"><a href="#">添加</a></li>
    </ul>
                <div class="col-sm-5">
                    <input type="text" class="form-control" id="orderJiphone" name="orderJiphone" value="${vo.orderJiphone}">
                </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="orderJiaddress" name="orderJiaddress" value="${vo.orderJiaddress}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">车辆编号:</label>
                <div class="col-sm-5">

运行环境

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

适用

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

功能说明

登录、注册、退出、用户模块、公告模块、订单模块、车辆模块的增删改查管理

20220319004053

20220319004054

20220319004055

20220319004056

20220319004057

20220319004058

20220319004059

20220319004100

20220319004101

20220319004102

20220319004103

20220319004104

20220319004105

document

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

举报

相关推荐

0 条评论