'using g tags in controller
I am using the following statement in a filter
if(g.cookie(name:'abc'))
it prompts an error: *
groovy.lang.MissingPropertyException: No such property: g for class: com.AFilters Possible solutions: log at com.AFilters$_closure1_closure4_closure10.doCall(AFilters.groovy:77) at java.lang.Thread.run(Thread.java:679)
*
Do I have to import some class to use the statement? I have used this in controller its not creating any error
Solution 1:[1]
You have to inject the grailsApplication and get the according bean.
See Can I use grails tag outside of GSP? for further information.
Solution 2:[2]
In controllers you should be able to use the tagLib code directly, without using the .g prefix.
if(cookie(name:'abc'))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Community |
| Solution 2 | Ruben |
