更新时间:2023-09-14 23:07:28
会话范围以编程方式提供 ExternalContext#getSessionMap()
,它将封底委托给 HttpSession#get / setAttribute()
。
The session scope is programmatically available by ExternalContext#getSessionMap()
which delegates under the covers to HttpSession#get/setAttribute()
.
Map<String, Object> sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
// ...
您当然也可以将托管bean放入会话范围。可以通过< managed-property>
从其他托管bean访问它(或者只使用托管bean名称作为映射键遍历会话映射)。
You can of course also just put a managed bean in the session scope. It's accessible from other managed beans by <managed-property>
(or just a traversal of the session map using the managed bean name as map key).