springMVC中controller之前执行的方法

来源:互联网 发布:创维电视无法连接网络 编辑:程序博客网 时间:2024/05/17 03:25
     @ModelAttribute()  
     public void getSessionUser() throws IOException, ServletException {
         HttpSession session = getSession();
         if (getLoginInfoFromSession()==null) {
             session.setMaxInactiveInterval(60*60);
             HttpServletRequest request = getRequest();
             String userId = request.getParameter("userId");
             String roleType = request.getParameter("roleType");
             if(userId==null||roleType==null){
                 request.getRequestDispatcher(request.getContextPath() + "/pages/error/500.html").forward(request, getResponse());
//                 getResponse().sendRedirect(request.getContextPath() + "/pages/error/500.html");
                 return;
             }
             List<AdminUser> adminUserList = adminUserService.getListByProperty("loginId",userId);
            
                LoginInfo loginInfo = new LoginInfo();
                AdminUser adminUser = adminUserList.get(0);
                if(adminUser.getSupplier()!=null&&AdminUser.ROLE_TYPE_SUPPLIER.equals(roleType)){
                    loginInfo.setSupplierId(adminUser.getSupplier().getId());
                    loginInfo.setSupplierName(adminUser.getSupplier().getSupplierName());
                }
                loginInfo.setRoleType(roleType);
                loginInfo.setAdminUser(adminUser);
                session.setAttribute(SESSION_LOGIN_INFO, loginInfo);
         }
     } 

0 0
原创粉丝点击