簡體   English   中英

在Liferay Portlet中設置的Velocity Template中檢索會話屬性

[英]Retrieving Session attributes in Velocity Template set in Liferay Portlets

在我的Portlet中,我在會話中設置了一些屬性,我希望在Liferay使用的速度模板中使用它。

我在PortletSession上設置屬性如下:

portletSession.setAttribute("key", "value", PortletSession.APPLICATION_SCOPE);

現在我希望在Liferay的home.vm模板中使用這些,但無論我嘗試什么,都沒有用:

$request.get("key") 
$request.getAttribute("key") 
$request.getSession().getAttribute("key")
$session.getAttribute("key")

我甚至把密鑰放在portal.properties中:

session.shared.attributes=key

但這似乎也不起作用。 誰能指出我正確的方向?

我自己找到了答案。

顯然我需要將private-session-attributes為false。 之前我嘗試過,但DTD在需要標簽的地方非常具體。

將它放在正確的位置后,它工作。

將“LIFERAY_SHARED_”前綴添加到會話屬性名稱應該足夠了,因為session.shared.attributes屬性的值默認包含它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM