简体   繁体   中英

Velocity calling a vararg method

I am trying to call a varargs method from Velocity. The function is defined in a Class named "Abc" as:

public static void function(String ... values)

I set the context as

params.put("concat",new Abc());

The template contains the call to the method as:

$concat.function('Var1','var2')

If I fix the function to have one argument everything works fine, if I move to the varargs (or a byte[] for that matter), it can't resolve it and I don't get back what I wanted. I set some log settings and go that velocity gets:

Null reference [template 'bufferTemplate', line 1, column 1] :
  $concat.function('Kuku','Muku') cannot be resolved.

I am using Velocity 1.6.4 and for me it works the way you've written! Update your Velocity! As far as I have seen they have support for varags from version 1.6 !

Got it. I'm using axis, which seems to be using an older version of Velocity. Once velocity was set first in the classpath, it works. Thanks for the help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM