有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (3) 个答案

  1. # 1 楼答案

    引自the developer guide

    Object [] Regular object array, not much needs to be said here. Velocity will internally wrap your array in a class that provides an Iterator interface, but that shouldn't concern you as the programmer, or the template author. Of more interest, is the fact that Velocity will now allow template authors to treat arrays as fixed-length lists (as of Velocity 1.6). This means they may call methods like size(), isEmpty() and get(int) on both arrays and standard java.util.List instances without concerning themselves about the difference.

    因此,使用size()java.util.List和java数组上同样有效

  2. # 2 楼答案

    我从未使用过Velocity,但它的VTL reference guide表示调用方法是使用$customer.getAddress()${purchase.getTotal()}完成的。所以我会使用${myArrayList.size()}

  3. # 3 楼答案

    可以像访问任何其他对象一样访问集合,因此$collection.size()将包含一个值

    数组special cased的行为类似于List,因此尽管$array.length不起作用,但$array.size()起作用

    在旧版本的Velocity(1.6之前)中,您将使用^{}^{}