2014-11-08 93 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);