This works as expected in a GSP-page:
<td>${Foo.findAllByBar(bar)}</td>
But when adding a collect statement the code breaks ..
<td>${Foo.findAllByBar(bar).collect { it.name }}</td>
with
Error 500: Could not parse script [...gsp]: startup failed,
...: 129: expecting '}', found ')'
@ line 129, column 196. 1 error`.
I was under the impression that any valid Groovy code could be placed in a GString ${ ... }
and being correctly evaluated/expanded. What am I missing?
Alternatively, you can use the spread operator:
<td>${Foo.findAllByBar(bar)*.name}</td>
The GSP parser doesn't like }
within the ${...}
block. Try this one:
<%= Foo.findAllByBar(bar).collect { it.name } %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With