簡體   English   中英

utilLocator.findUtil(“com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil”)未定義

[英]utilLocator.findUtil(“com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil”) is undefined

我在ADT自定義模板代碼中使用以下代碼

<#assign storageEngineUtil = utilLocator.findUtil("com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil") />

但是這給了utilLocator.findUtil("com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil") is undefined

這里有什么我想念的嗎?

無法從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") />

暫無
暫無

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

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