In my java/spring app, I have a velocity template in which I create a map which will hold values also inserted in the template:
#set ($myMap = {})
What I want to do is have an if/else checking if the map is empty. This doesn't seem to be working for me. I've tried:
#if ($myMap.empty)
...
#if ($myMap.size == 0)
Neither of these work. What is the correct way to check if a Map is empty in velocity. I've tried searching the Documentation and SO, but I can't find an example.
isEmpty
and size
are methods, so they should be used like this:
#if ($myMap.isEmpty())
...
#if ($myMap.size() == 0)
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