1

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}/?=)}" />
BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513
Bart van Heukelom
  • 41,958
  • 59
  • 182
  • 293

2 Answers2

4

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)}" />
BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513
0

Depending on what the function r:urlEncode does, you may be able to use an expression like:

${r:urlEncode(game.index)}${r:urlEncode('/?=')}
McDowell
  • 105,511
  • 29
  • 196
  • 262