String concatenation in JSP EL, inside a function [duplicate]
How can I do a concatenation like this in EL
<c:out value="${r:urlEncode(game.index+'/?=')}" />
This doesn't work because it wants to add game.index and '/?=' as numbers, which would be rather silly.
I've also tried this, which doesn't work either:
<c:out value="${r:urlEncode(${game.index}/?=)}" />
That's not possible with EL. In EL, the +
is exclusively a numerical (sum) operator.
Use <c:set>
beforehand.
<c:set var="url" value="${game.index}/?=" />
<c:out value="${r:urlEncode(url)}" />
Depending on what the function r:urlEncode
does, you may be able to use an expression like:
${r:urlEncode(game.index)}${r:urlEncode('/?=')}
精彩评论