![](/img/trans.png)
[英]com.liferay.portlet.asset.AssetCategoryException
[英]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.