Search code examples
grailsgroovygsp

GSP use set variable as counter


I have a problem using a variable from a webflow as a counter

I tried several possibilities

 <g:set var="count" value="${flow.ipcount  as Integer}" />
                 <g:each in="${ (1..'${count}' ) }">

and

<g:set var="count" value="${flow.ipcount}" />
                 <g:each in="${ (1..'${count}' ) }">

But I get only an error: Message:java.lang.String cannot be cast to java.lang.Integer


Solution

  • You don't need the inner ${}:

    <g:each in="${ (1..count) }">