How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
legacy-article
learn-legacy-article-disclaimer-text
問題
Web コンテンツを表示しようとすると、いくつかの問題が発生します。
シナリオ 1: 検索結果ページに Web コンテンツを表示しようとしています。 検索結果の Web コンテンツの一部に、エラー メッセージ「テンプレートの処理中にエラーが発生しました。 以下は null または不足していると評価されました: ==> webContentData.title".
シナリオ 2: Web コンテンツ表示ウィジェットに表示する Web コンテンツを選択しようとしています。 Web コンテンツの説明は、エラー メッセージ「テンプレートの処理中にエラーが発生しました。 以下は null または不足していると評価されました: ==> webContentData.title"
どちらのシナリオでも、次のスタック トレースが共通しています。
2022-05-13 13:30:18.653 ERROR [http-nio-8080-exec-7][runtime:59] Error executing FreeMarker template FreeMarker template error: The following has evaluated to null or missing: ==> webContentData.title [in template "20101#20128#null" at line 6, column 11]
---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to 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: ${webContentData.title} [in template "20101#20128#null" at line 6, column 9] ----
Java stack trace (for programmers): ---- freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...] at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134) at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:479) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:401) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:370) at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:100) at freemarker.core.DollarVariable.accept(DollarVariable.java:63) at freemarker.core.Environment.visit(Environment.java:331) at freemarker.core.Environment.visit(Environment.java:337) at freemarker.core.Environment.process(Environment.java:310) at freemarker.template.Template.process(Template.java:383) at com.liferay.portal.template.freemarker.internal.FreeMarkerTemplate.processTemplate(FreeMarkerTemplate.java:154) at com.liferay.portal.template.BaseTemplate.processTemplate(BaseTemplate.java:163) at com.liferay.journal.internal.transformer.JournalTransformer.doTransform(JournalTransformer.java:367) at com.liferay.journal.internal.transformer.JournalTransformer.transform(JournalTransformer.java:103) at com.liferay.journal.internal.util.JournalUtil.transform(JournalUtil.java:424) at com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.getArticleDisplay(JournalArticleLocalServiceImpl.java:7987) at com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.getArticleDisplay(JournalArticleLocalServiceImpl.java:2536) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50) at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:69) at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57) at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49) at com.sun.proxy.$Proxy875.getArticleDisplay(Unknown Source) at com.liferay.journal.service.JournalArticleLocalServiceUtil.getArticleDisplay(JournalArticleLocalServiceUtil.java:1448) at com.liferay.journal.web.internal.asset.model.JournalArticleAssetRenderer.getSummary(JournalArticleAssetRenderer.java:244) at org.apache.jsp.view_jsp._jspService(view_jsp.java:812) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111) . . .
Environment
Liferay DXP 7.2
Liferay DXP 7.3
解決策
Freemarker テンプレートのコンパイル エラーの根本的な原因は、Web コンテンツが関連するテンプレートのない構造に基づいていることです。 さらに、構造体の定義には Web コンテンツ フィールド (タイプ«ddm-journal-article») があり、このフィールドには値が割り当てられていません。
FreeMarker template error: The following has evaluated to null or missing: ==> webContentData.title [in template "20101#20128#null" at line 6, column 11]
解決策は、構造内の Web コンテンツ フィールド (タイプ«ddm-journal-article») に値を割り当てることです。