我想将此行从 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
关于java - 如何将此行从 Velocity 转换为 FreeMarker?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33890672/