java - Using varargs in a Tag Library Descriptor -


is possible have tld map following function:

public static <t> t[] toarray(t... stuff) {     return stuff; } 

so can do:

<c:foreach items="${my:toarray('a', 'b', 'c')}"... 

i tried following <function-signature>s

java.lang.object toarray( java.lang.object... ) java.lang.object[] toarray( java.lang.object[] ) 

and others nothing seems work.

unfortunately that's not possible. el resolver interprets commas in function separate arguments without checking if there methods taking varargs. best bet using jstl fn:split() instead.

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> ...     <c:foreach items="${fn:split('a,b,c', ',')}" var="item">     ${item}<br/> </c:foreach> 

it have been nice feature in el however, although implementing pretty complex.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -