Is it possible to have a TLD map to the following function:
public static <T> T[] toArray(T... stuff) {
return stuff;
}
So that I can do:
<c:forEach items="${my:toArray('a', 'b', 'c')}"...
I tried the following <function-signature>s
java.lang.Object toArray( java.lang.Object... )
java.lang.Object[] toArray( java.lang.Object[] )
And others but nothing seems to work.
Unfortunately that’s not possible. The EL resolver immediately interprets the commas in the function as separate arguments without checking if there are any methods taking varargs. Your best bet is using JSTL
fn:split()instead.It would have been a nice feature in EL however, although implementing it would be pretty complex.