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();
            }
    
    
        }

      

  • 相关阅读:
    KLSudoku的数独题目生成方法和难度控制说明
    对XChain和ForcingChain的实现解说
    开源数独游戏软件KLSudoku发布第一个Release版本
    每个 Vim 用户都应该阅读的文章
    自己常用的几个gvim的vimrc设置
    KLSudoku数独游戏软件1.1预览版发布
    KLSudoku数独游戏软件1.1正式版发布
    字符串
    .NET面试大全
    IIS是如何处理ASP.NET请求的
  • 原文地址:https://www.cnblogs.com/CL-King/p/13833649.html
Copyright © 2011-2022 走看看