Hello World With Grails
2009-11-21 11:47:43 | 0 Comment
I don't like Java but there is something for real; JVM is stable. Since I don't like Java I thought I could give a try to Grails as it is built on Groovy which runs on JVM. This is a simple tutorial that I explain how to create a very simple Hello World application with Grails.
Creating the Application
--------
In order to create a Grails application, "grails create-app" command is used. In our case, we will simply type in our terminal:
# cd into the directory where you want to create your grails applications.
cd ~/projects/grails
grails create-app hello
Creating the Controller
--------
We will create the Grails controller for our application by typing:
grails create-controller Hello
This command will generate our controller class. Now all we have to do is just typing a text in our controller.
Open ../hello/grails-app/controllers/HelloController.groovy. Its content should be like the following.
class HelloController {
def index = { }
}
What we are going to do is just rendering a text like this:
class HelloController {
def index = {
render "My First Grails Application"
}
}
Starting the Server
--------
The next step is starting the Grails server.
grails run-app
And point your browser to [http://localhost:8080/hello/hello/index](http://localhost:8080/hello/hello/index) and get greeted! :)
Check my latest project compector.com where you can post references about your former employers and see what others have said about the future employers. Sign up now and post a reference and share it on twitter or facebook.


Comments
Leave a Response