[英]How to convert this line from Velocity to FreeMarker?
我想將此行從Velocity轉換為Freemarker:
#set ($valid_portlet_description = $validator.isNotNull($portlet_description)
&& $portlet_description.indexOf('javax.portlet.description') == -1)
我試圖將代碼更改為:
<#assign valid_portlet_description = validator.isNotNull(portlet_description)
&& portlet_description?index_of("javax.portlet.description") == "-1" />
但是我得到以下錯誤:
freemarker.template.TemplateException
:唯一合法的比較是兩個數字,兩個字符串或兩個日期之間的比較。 左手操作數是freemarker.template.SimpleNumber
右手操作數是freemarker.template.SimpleScalar
該消息抱怨此聲明:
portlet_description?index_of("javax.portlet.description") == "-1"
它說您有不同的類型:左邊的數字,右邊的SimpleScalar
(在Freemarker中只是String
)。 要解決此問題,您應該刪除引號:
portlet_description?index_of("javax.portlet.description") == -1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.