1 /** 2 * 获取全局Session 3 * @return 4 */ 5 @SuppressWarnings("unchecked") 6 public static String findAdminFromSession(){ 7 try{ 8 HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); 9 Map<String,User> map = (Map) WebUtils.getSessionAttribute(request,"user"); 10 User user = map.get("userInfo"); 11 return user!=null?(StringUtils.isNotBlank(user.getId())? user.getId(): null):null; 12 }catch(Exception e){ 13 e.printStackTrace(); 14 return null; 15 } 16 17 }
User视情况而定