增加VTL中的操作

时间:2011-03-07 13:48:38

标签: velocity vtl

我正在尝试在VTL中使用substring方法,如下所述

#set ($Score = $row.getValue("Score").substring(0,$row.getValue("Score").length()-1))

但它说

    Encountered "-1" at 
Was expecting one of:
   "," ...
   ")" ...
   <WHITESPACE> ...
   <DOT> ...

请帮我解决这个问题。

由于 基肖尔马布

1 个答案:

答案 0 :(得分:0)

#set( $value = $row.getValue("Score") )
#set( $len = $value.length() - 1 )
#set( $Score = $value.substring(0, $len))

或者,如果你使用VelocityTools,你可以做这个丑陋的事情:

#set( $Score = $row.getValue("Score").substring(0, $math.sub($row.getValue("Score").length(), 1) )