开发者

String concatenation in JSP EL, inside a function [duplicate]

This question already has answers here: How to concatenate a String in EL? (5 answers) Closed开发者_运维问答 6 years ago.

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('/?=')}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜