Java – how to use El JSTL to convert arbitrary objects to strings? (call tostring())
•
Java
Is there a way to call toString () in an object with EL and JSTL? (I need an enumerated string representation as an index in the mapping in the JSP El expression.) I hope things like ${"object} work like Java, but el is not very good and doesn't seem to do any function
Clarification: I have a variable soap map string to string, and I have a variable someenum which is an enumeration I want to do something like ${soap memap [someenum. Tostring()]} Of course. ToString () doesn't work, but what
Solution
You just do this:
${object}
It will give you
Edit: your nested expression can be parsed like this:
<c:set var="myValue">${someenum}</c:set> ${somemap[myValue]}
The first line uses (using tostring()) ${someenum} expression and stores it in the myvalue variable The second line uses myvalue to index the map
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码