2014-11-08 95 views
3

如果想要在目標portlet中清除那個sessionAttribute但通過數據到另一個portlet,但不起作用。在liferay中刪除jsp portlet中的會話屬性問題

在目標portlet中,我獲得會話屬性並清除它,但在刷新JSP頁面之後。會話屬性仍然存在。它應該是null。我如何擺脫這一點,因爲下面的代碼不工作。

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %> 
<%@page import="javax.portlet.PortletSession" %> 
<portlet:defineObjects /> 

This is the <b>NewPPIPC</b> portlet in View mode. 

<% 

PortletSession ps = renderRequest.getPortletSession(); 
String qString = (String)ps.getAttribute("sessionValue",PortletSession.APPLICATION_SCOPE); 
ps.removeAttribute("sessionValue"); 

%> 

<h1><%=qString %></h1> 

回答

1

重載方法使用PORTLET_SCOPE搜索的對象,但你需要指定一個範圍APPLICATION_SCOPE

ps.removeAttribute("sessionValue", PortletSession.APPLICATION_SCOPE);