Liferay 共享会话属性?

Liferay 共享会话属性?,liferay,session-variables,Liferay,Session Variables,我在liferay门户中有两个portlet:一个MVCPortlet和一个VaadinPortlet 第一个设置会话属性的方式如下: long serviceId = 1; PortletSession portSession = renderRequest.getPortletSession(); portSession.setAttribute("serviceId", serviceId, PortletSession.APPLICATION_SCOPE); 第二条是: Portl

我在liferay门户中有两个portlet:一个MVCPortlet和一个VaadinPortlet

第一个设置会话属性的方式如下:

long serviceId = 1;
PortletSession portSession = renderRequest.getPortletSession();
portSession.setAttribute("serviceId",   serviceId, PortletSession.APPLICATION_SCOPE);
第二条是:

PortletRequest portletRequest = VaadinPortletService.getCurrentPortletRequest();
long serviceId = (long) portletRequest.getPortletSession().getAttribute("serviceId", PortletSession.APPLICATION_SCOPE)
问题是第二个portlet读取的会话属性为null,而不是1。 我做错了什么

请在
liferayportlet.xml
中为这两个portlet添加
false

根据DTD,该标签的详细信息如下:

元素:私有会话属性设置 如果portlet没有,则private session attributes值为true 与门户共享会话属性。默认值为true。 portal.properties中的属性“session.shared.attributes”
指定哪种会话属性是共享的,即使在
私有会话属性值为true

数据类型:#PCDATA

在liferay portal-ext.properties文件中。 所有以关键字“Shared”开头的变量都将是应用程序范围。 如果完成此操作,则无需设置

<private-session-attributes>false</private-session-attributes>
false

两个portlet中的私有会话属性设置均为false:false
<private-session-attributes>false</private-session-attributes>