1

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

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

但它说

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

请帮我解决这个问题。

谢谢基肖尔

4

1 回答 1

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) )
于 2011-03-07T16:01:27.087 回答