Thursday, December 22, 2016

Actions in Play Framework 2.5

Requests that come to application based on Play usually are processed by thing which is called action.

Action it is just a method that processes parameters of requests and sends result back to web client

Let's look on example below

package controllers;

import play.mvc.*;

 * This controller contains an action to handle HTTP requests
 * to the application's home page.
public class HomeController extends Controller {

     * An action that renders an HTML page with a welcome message.
     * The configuration in the routes file means that
     * this method will be called when the application receives a
     * GET request with a path of /.
    public Result index() {
        return ok("Hello World!");


We see an action index that return Result (HTTP response which we send to web client).

No comments :