2015-11-24 24 views
0

我想這條線從速度轉換爲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 : The only legal comparisons are between two numbers, two strings, or two dates. Left hand operand is a freemarker.template.SimpleNumber Right hand operand is a freemarker.template.SimpleScalar

+1

請注意,您應該更新FreeMarker。 2.3.23給出了更容易理解的錯誤信息。 – ddekany

+0

謝謝@ddekany! :) –

回答

1

的消息抱怨此聲明:

portlet_description?index_of("javax.portlet.description") == "-1" 

它說,你有不同的類型:左邊的數字,但SimpleScalar(這只是在Freemarker條款String)在右邊。要解決這個問題,您應該刪除引號:

portlet_description?index_of("javax.portlet.description") == -1 
+0

非常感謝你! –