How to convert an arbitrary object to String with EL? (calling toString())
Posted
by hstoerr
on Stack Overflow
See other posts from Stack Overflow
or by hstoerr
Published on 2010-05-21T16:20:14Z
Indexed on
2010/05/21
19:20 UTC
Read the original article
Hit count: 207
Is there any way to call toString() on an object with the EL? (I need the String representation of an enum as index in a map in a JSP EL expression.) I hoped something like ${''+object}
would work like in java, but EL isn't that nice, and there does not seem to be any function that does it.
Clarification: I have a variable somemap
that maps Strings to Strings, and I have a variable someenum
that is an enumeration. I'd like to do something like ${somemap[someenum.toString()]}
. (Of course .toString() does not work, but what does?)
© Stack Overflow or respective owner