Controller Usage 控制器用法
A controller fulfills the C in the Model View Controller (MVC) pattern and is responsible for handling web requests. In Grails a controller is a class that ends in the convention "Controller" and lives in the grails-app/controllers directory. A controller can be created with the create-controller command:
控制器是模型/视图/控制器(MVC)模式中控制器(C)的实现,而且负责处理web请求。在Grails中一个控制器就是以“Controller”结尾并且在grails-app/controllers目录下的一个类,你可以通过create-controller命令来创建:
grails create-controller hello
Or via your favourite IDE or text editor.
或者是你喜欢的IDE/文本编辑器。
class HelloController {
def world = {
render "Hello World!"
}
} Each action in the controller is a callable block (for example the world action above) that has access to a number of implicit variables and methods which are covered in this reference documentation.Refer to the user guide topic on Controllers for more information.
更多信息请参照用户指南中的控制器主题。