Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a random integer in Freemarker template?

Is it possible to generate a random integer in Freemarker template?

like image 851
Eeyore Avatar asked Sep 09 '10 20:09

Eeyore


2 Answers

Freemarker does not provide a random number generator at the moment. You can implement a naive random number generator using the time ( .now ) as a seed, but it should never be a critical part of your program.

like image 178
Kayhadrin Avatar answered Jan 03 '23 01:01

Kayhadrin


You can generate a random integer in Java and pass this integer to the Freemarker template.

like image 35
Daniel Moura Avatar answered Jan 03 '23 01:01

Daniel Moura