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,082,665
  • 372
  • 3,610
  • 3,555
Bart van Heukelom
  • 43,244
  • 59
  • 186
  • 301

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,082,665
  • 372
  • 3,610
  • 3,555
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
  • 107,573
  • 31
  • 204
  • 267