session的获取

Springmvc:

RequestAttributes ra = RequestContextHolder.getRequestAttributes();
HttpServletRequest request = ((ServletRequestAttributes)ra).getRequest();
request.getSession().setAttribute("sessionMessage", "im'sessionMessage!");
属性设置也可以使用putValue(已弃用),和setAttribute一样;

HttpSession session=request.getSession();

Struts2:

Map<String,Object> session=ActionContext.getContext.getSession();
session.put(Constant.SESSION_USER_KEY,userVO);

posted @ 2018-09-10 12:50  笔记Next  阅读(577)  评论(0编辑  收藏  举报