如何将此行从 Velocity 转换为 FreeMarker?
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
: 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
留言投诉此说法:
portlet_description?index_of("javax.portlet.description") == "-1"
它说你有不同的类型:左边的数字,右边的 SimpleScalar
(在 Freemarker 术语中就是 String
)。要解决此问题,您只需删除引号:
portlet_description?index_of("javax.portlet.description") == -1
我想将此行从 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 afreemarker.template.SimpleNumber
Right hand operand is afreemarker.template.SimpleScalar
留言投诉此说法:
portlet_description?index_of("javax.portlet.description") == "-1"
它说你有不同的类型:左边的数字,右边的 SimpleScalar
(在 Freemarker 术语中就是 String
)。要解决此问题,您只需删除引号:
portlet_description?index_of("javax.portlet.description") == -1