I was reading Struts2 In Action, and it says for each request an ActionContext
, a ValueStack
and an Action
instance are created, so they are thread safe. I was wondering how does the framework manages session, because it can't be stored in these locations, where does the actual Map gets stored, and how concurrent access to that Map is managed by the framework?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The http session is stored in the SessionMap
which is among the other context maps is stored in the action context by the dispatcher when serving a request. The session map is a wrapper for http session object and operations such as get
/put
are synchronized using a http session object monitor. It simply synchronizes the access to http session attributes, however providing a Map
implementation.