嗨夥伴Liferay'ers,Liferay 7 Freemarker模板 - 獲取文章分類
我試圖用Freemarker模板得到一個journalArticle的類別。
我試過這段代碼:
<#assign journalArticleId = .vars['reserved-article-id'].data>
<#assign journalArticleResourceLocalServiceUtil = staticUtil["com.liferay.portlet.journal.service.JournalArticleResourceLocalServiceUtil"]>
<#assign assetCategoryLocalServiceUtil = staticUtil["com.liferay.portlet.asset.service.AssetCategoryLocalServiceUtil"]>
<#assign articleResourcePK = journalArticleResourceLocalServiceUtil.getArticleResourcePrimKey(groupId, journalArticleId)/>
<#assign categoryList=assetCategoryLocalServiceUtil.getCategories("com.liferay.portlet.journal.model.JournalArticle",articleResourcePK) >
<#list categoryList as categoryList>
${categoryList.getName()}
</#list>
當我執行的代碼,它拋出這個錯誤:
08:26:30,582 ERROR [http-nio-8080-exec-10][runtime:60] Error executing FreeMarker template
FreeMarker template error:
The following has evaluated to null or missing:
==> staticUtil [in template "20202#20246#41671" at line 14, column 51]
----
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: #assign journalArticleResourceLocalSe... [in template "20202#20246#41671" at line 14, column 1]
----
Java stack trace (for programmers):
----
有沒有人有一個想法是什麼,我做錯了什麼? 預先感謝您。
在[THIS]中回答的問題(http://stackoverflow.com/questions/38241049/liferay-7-freemarker-template-staticutil-has-evaluated-to-null-o r-missing-tri/38302812?noredirect = 1#comment64023270_38302812)Post – balex