(Quick Reference)

create-filters

目的
Purpose

The create-filters command creates a Grails filters class for the given base name.

使用例
Examples

grails create-filters
grails create-filters logging
grails create-filters org.bookstore.Logging

詳細
Description

Creates a filters class for the given base name. For example, for a base name of org.bookstore.Logging a filters class called LoggingFilters will be created in the grails-app/conf/org/bookstore directory. The argument is optional, but if you don't include it the command will ask you for the name of the filters class.

A filters class allows you to execute code before and after a controller action is executed and also after any view is rendered.

The name of the filters class can include a Java package, such as org.bookstore in the final example above, but if one is not provided a default is used. So the second example will create the file grails-app/conf/<appname>/LoggingFilters.groovy whereas the last one will create grails-app/conf/org/bookstore/LoggingFilters.groovy directory. Note that the first letter of the name is always upper-cased when determining the class name.

If you want the command to default to a different package for filters classes, provide a value for grails.project.groupId in the runtime configuration.

Note that this command is just for convenience and you can also create filters in your favorite text editor or IDE if you choose.

使用方法:

Usage:

grails create-filters [name]

発生するイベント:

Fired Events:
  • CreatedFile - When the filters class has been created