ActionContext.getContext().getSession() 和 HttpSession session = ctx.getSession(); 中session的区别

① Map session = ServletActionContext.getContext().getSession(); 

②                          ActionContext.getContext().getSession(); 

③ WebContext ctx = WebContextFactory.get();
     HttpSession session = ctx.getSession();


① The acquired session is a native session, you can call the setAttribute() method

② The acquired session is a Map-type session encapsulated by struts, and the data can only be cached by calling the put() method.

②and ③The first one is to save the value in the session, the effect is equivalent to session.setAttribute("",""),

     The former is an encapsulation of the latter by struts2, which puts the session, request, and application in the actioncontext() container.

Guess you like

Origin blog.csdn.net/qie_wei/article/details/104720216