zoukankan      html  css  js  c++  java
  • 超市订单管理系统,用户管理实现

     用户管理功能概述:

      功能1 :展示用户信息

          

      

     利用动态sql实现分页功能,链表查询实现多表整合

      public void query(HttpServletRequest req, HttpServletResponse resp){
    
            //查询用户列表
            //从前端获取数据
            String queryUserName = req.getParameter("queryname");
            String temp = req.getParameter("queryUserRole");
            String pageIndex = req.getParameter("pageIndex");
            int queryUserRole = 0;
    
            //获取用户列表
            UserServiceImpl userService = new UserServiceImpl();
    
            //第一次走这个页面,一定是第一页,页面大小是固定的
            int pageSize = 5;//可以把这个写到配置文件中,方便后期修改
            int currentPageNo=1;
    
    
            if (queryUserName == null){
                queryUserName = "";
            }
    
            if (temp!=null&& !temp.equals("")){
                queryUserRole =Integer.parseInt(temp);//解析页面,转换成整数型
            }
            if(pageIndex!=null){
                try {
                    currentPageNo = Integer.parseInt(pageIndex);
                } catch (Exception e) {
                    try {
                        resp.sendRedirect("error.jsp");
                    } catch (IOException ioException) {
                        ioException.printStackTrace();
                    }
                }
            }
    
            //获取用户总数(分页:上一页,下一页情况)
            int totalCount = userService.getUserCount(queryUserName, queryUserRole);
            //总页数支持
            PageSupport pageSupport = new PageSupport();
            pageSupport.setCurrentPageNo(currentPageNo);
            pageSupport.setPageSize(pageSize);
            pageSupport.setTotalCount(totalCount);
    
            //通过分页支持的公共类,查出一共有几页
            int totalPageCount=pageSupport.getTotalPageCount();
    
            //控制尾页和首页
            if (currentPageNo<1){
                currentPageNo = 1;
            }else if (currentPageNo>totalPageCount){//当页面大于最后一页
                currentPageNo=totalCount;
            }
    
            //获取用户展示
            List<User> userList = userService.getUserList(queryUserName, queryUserRole, currentPageNo, pageSize);
            req.setAttribute("userList",userList);
    
            RoleServiceImpl roleService = new RoleServiceImpl();
            List<Role> roleList = roleService.getRoleList();
            req.setAttribute("roleList",roleList);
    
            req.setAttribute("totalCount",totalCount);
            req.setAttribute("currentPageNo",currentPageNo);
            req.setAttribute("totalPageCount",totalPageCount);
            req.setAttribute("queryUserName",queryUserName);
            req.setAttribute("queryUserRole",queryUserRole);
    
            //返回前端
            try {
                req.getRequestDispatcher("userlist.jsp").forward(req,resp);
            } catch (ServletException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
    
    
        }

      

  • 相关阅读:
    凹凸函数
    HashMap数据类型使用注意不能使用基本数据类型
    Tomcat部署发布JSP应用程序的三种方法
    Ubuntu忘记密码,进不了系统的解决方法
    matlab之运算符及其优先级
    java和tomcat配置
    MySQL中 MySQL X.X Command Line Client 一闪而过
    Pearson(皮尔逊)相关系数
    CG, DCG, NDCG
    C#中ListBox中SelectedItem使用注意
  • 原文地址:https://www.cnblogs.com/CL-King/p/13833649.html
Copyright © 2011-2022 走看看