egg li
egg li

Reputation: 37

Grails How to use annotation to filter the controller action

How can i use annotation to filter the the specific controller's action ? If the method use this annotation, then the method will go in to the filter

Upvotes: 0

Views: 870

Answers (1)

Burt Beckwith
Burt Beckwith

Reputation: 75681

It's not clear what you want to do, but I wrote a blog post a few years ago that is still valid, and it describes a way to annotate controller actions and make decisions in filters based on the values in the annotations.

One thing that is different now is that controller actions are usually methods, but at that time only closures were supported. So you would need to change the annotations a bit; change @Target({ElementType.FIELD, ElementType.TYPE}) (which says the annotation is allowed at the class level (type) or on closures (field)) to @Target({ElementType.METHOD, ElementType.TYPE}), or @Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) if you want to continue to annotate closures and methods.

Upvotes: 1

Related Questions