2014-07-23 81 views
0

我使用Spring Web Flow的的Spring Portlet訪問會話(即一個portlet中是很重要的)從Spring Web Flow的

我怎樣才能獲得會話(HttpSession的)對象從網絡流量???

我知道,彈簧提供特殊的變量,比如externalContextflowRequestContext, 但我無法弄清楚如何讓會議從對象

回答

0

在Spring的Portlet Webflow的組合: 您可以通過訪問的ExternalContext sessionMap。 porlet的實現是PortletExternalContext,它有兩個會話映射可用:globalSessionMap和sessionMap。 您可以訪問它:

<evaluate expression="externalContext.globalSessionMap.yourSessionAttribute" result="store it somewhere"/> 

    <evaluate expression="externalContext.sessionMap.yourSessionAttribute" result="store it somewhere"/> 

在ServletContext中,這些地圖返回相同的值。

UPDATE:

如果您需要會話(Portlet會話)明確的訪問本身,而不是通過sessionMap屬性如上面提到的,你可以得到它爲:

<evaluate expression="externalContext.nativeRequest.portletSession" result="store this session object somewhere"/> 

這裏nativeRequest對象PortletRequest對象。

說了這麼多,如果這些屬性放在APPLICATION_SCOPE中的portlet會話中,那麼它們可以在servlet會話範圍內訪問。 我懷疑你是否可以獲得HttpSession對象,但屬性可以。