我正在开发一个 JSF 2 Portlet,但我需要获取全局会话变量。
该请求适用于:
FacesContext facesContext = FacesContext.getCurrentInstance();
PortletRequest request = (PortletRequest) facesContext.getExternalContext().getRequest();
但会话为空:
PortletSession session = request.getPortletSession(false);
如果将此代码放在 liferay-portlet.xml 文件中可以正常工作,但我不能进行 IPC:Inter Portlet 通信
<!-- Portlet session -->
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
我如何在不使用最后一个代码的情况下获取和设置变量会话?
谢谢
今天我尝试了这个:
FacesContext facesContext = FacesContext.getCurrentInstance();
PortletRequest request = (PortletRequest) facesContext.getExternalContext().getRequest();
HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(request);
HttpSession session = httpRequest.getSession(true);
System.out.println(session.getAttribute("XXXX"));
但为空