Sun GlassFish Enterprise Server v3 Scripting Framework Guide

Creating a Simple Grails Application

To create and run a simple helloworld application, perform the following tasks:

For more information on creating Grails applications, see the Grails Quick Start.

ProcedureTo Create the helloworld Application

  1. Change to the as-install/grails/samples directory.

  2. Run the grails create-app helloworld command.

    The grails create-app command creates a helloworld application that you can modify.

ProcedureTo Create the hello Controller

  1. Change to the as-install/grails/samples/helloworld directory.

  2. Run the grails create-controller hello command.

    The grails create-controller command creates a controller file that you can modify in the /grails/samples/helloworld/grails-app/controllers directory:

  3. Edit the generated HelloController.groovy file so that it looks as follows:

    class HelloController {
    
           def world = {
                    render "Hello World!"
            }
        //def index = { }
    }