Java Reference
In-Depth Information
Note Resources stored in the public directory are static assets that will be served directly by the
web server.
target : The target directory contains everything generated by the build system
such as the following:
classes : This contains all the compiled classes (from both Java and Scala
sources).
classes_managed : This contains only the classes that are managed by the
framework (such as the classes generated by the router or the template system).
resource_managed : This contains generated resources, typically compiled assets
such as LESS CSS and CoffeeScript compilation results.
src_managed : This contains generated sources, such as the Scala sources
generated by the template system.
test : This last folder will contain all the test files along with some samples
provided by the framework.
Now that you have seen the directory structure of the application, you will learn how the default
welcome page is displayed when you test the URL: http://localhost:9000 .
Each row in the conf/routes file is a route that defines how to access server components using HTTP.
If you see the generated routes file in the conf/routes file, you will see this first route:
GET / controllers.Application.index()
This route is composed of three parts:
GET : This is the first part in the route (row) that contains the HTTP method used
in the request.
/ : This is the second part in the route that contains a relative path.
controllers.Application.index() : This is the third part in the route that
contains the action to be invoked.
These three parts in the route inform Play 2 that when the web server receives a GET request for
the / path, it must call controllers.Application.index() , which calls the index method in the
Application class that resides in the controllers package.
Now you will see what the controllers.Application.index method looks like. For that, you need to
open the app/controllers/Application.java source file. This file is illustrated in Listing 8-1.
Listing 8-1. Application Controller
1. package controllers;
2.
3. import play.*;
4. import play.mvc.*;
 
Search WWH ::




Custom Search