java 里面获取session对象

1.在springmvc中:

HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();

3.通过ServletActionContext获取

   HttpServletRequest request = ServletActionContext.getRequest(); 

   HttpSession session = request.getSession(); 

String userSession = request.getSession().getAttribute("userId")+StringUtil.EMPTY;

java 里面获取session对象_第1张图片

 

 

 

你可能感兴趣的:(Java)