Grails Controller
Grails Controller:
- Controller is main bridge between you view and model (As our last part we discuss domain which is model in our MVC).
- Main work of controller is handle web request .
- In Grails controller is a class with a name with with suffix Controller (e.g. BookController or AuthorController etc.)
- We put you controller in grails-app/controllers directory.
- You can create your controller with commend line with command: grails create-controller controllerName (e.g. grails create-controller org.book ,this commend create BookController in org package in grails-app/controllers directory ).
- A controller have many Action, Actually action is a method or closure which handle a particular web request of controller means if you have a BookController who deals with your Book related web request like create book , update book, delete book etc , Now you will create each action for handle these request eg.
Class BookControoler {
def createBook()
{
----your business logic for create book---
}
def updateBook()
{
----your business logic for update book---
}
}
We will discuss about action letter.


Comments
Post a Comment