Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails GSP <g:set> tag set as integer?

Tags:

Using Grails' GSP <g:set> tag, is it possible to specify the type of the variable? I want to declare an integer variable, but <g:set> always declares a sting. For example:

<g:set var="x" value="100"/> ${x.getClass()} ${x+23} 

results in

class java.lang.String 10023 

I'd like to declare x as an integer. I noticed that using the JSP tag <% int x=100; %> results in:

class java.lang.Integer 123 

Is there a way to do this the Grails/GSP way?

like image 632
Steve Kuo Avatar asked Dec 13 '09 01:12

Steve Kuo


1 Answers

Use the ${} syntax when defining the value. For example:

<g:set var="x" value="${100}"/> 

You can see the tag doc for g:set for more info.

like image 157
Jason Gritman Avatar answered Sep 26 '22 00:09

Jason Gritman