I've been trying to put some if logic into my grails _form.gsp. Basically I want it to add an extra line to a table if model I'm passing in is null, but its not working!
I have this: -
<g:if test="${results = null}">
banana
</g:if>
And it does nothing. I tried: -
<g:if test="${results.isEmpty()}">
But that causes the page to error on load with the message: -
Cannot invoke method isEmpty() on null object
If I try the reverse logic with <g:if test="${results != null}">
this works absolutely fine in scenarios where I know the model being passed in isn't empty! What am I missing?
you need a double "==" for your if statement:
<g:if test="${results == null}">
^
|
Since its Grails..
<g:if test="${ !results }">
would also work.. Just a shorter version
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.