根据我找到的文档,我写了 if 表达式。这是我尝试过的:
{% if idol_response.didYouMean != "" %}
<p>aaaaaaa</p>
{% endif %}
还:
{% if (idol_response.didYouMean != "") %}
<p>aaaaaaa</p>
{% endif %}
和:
{% if (not idol_response.didYouMean == "") %}
<p>aaaaaaa</p>
{% endif %}
以上任何一项都不起作用,这让我感到紧张;-)前两个给出:
HTTP Status 500 - Request processing failed; nested exception is com.lyncode.jtwig.exception.CompileException: Unable to find implementation for operator !=
我不评论第三个表达式,因为我承认它的语法不正确。根据所有来源,前两个应该没问题。didYouMean 是idol_response 对象的一个字段,我需要检查它是否为空。
我将不胜感激任何帮助。