2015-11-16 31 views

回答

2

不能從Freemarker模板訪問util類AssetEntryLocalServiceUtil。您要做的是訪問AssetEntryLocalService。在ADT模板中限制訪問Liferay服務。

你可以通過ServiceLocator得到AssetEntryLocalService的實例,但是你必須告訴Liferay允許它。

默認配置限制訪問serviceLocator變量(在portal.properties中)。

# 
# Set a comma delimited list of variables the FreeMarker engine cannot 
# have access to. This will affect Dynamic Data List templates, Journal 
# templates, and Portlet Display templates. 
# 
freemarker.engine.restricted.variables=serviceLocator 

設定需要portal-ext.properties被重寫到空值(即允許在serviceLocator模板的使用)。

然後你終於可以撥打serviceLocator.findService來獲得服務。

<#assign assetEntryLocalService = serviceLocator.findService("com.liferay.portlet.asset.service.AssetEntryLocalService") /> 
+0

謝謝托馬斯皮諾斯。我的問題已修復。 –

+0

好。如果你喜歡我的回答,請接受它。要將答案標記爲已接受,請單擊答案旁邊的複選標記以將其從空心切換爲綠色。 –