André Henriques André Henriques - 2 months ago 6
Java Question

Routes dont work in playframework 2.5

I am developing in playframework 2.5, but the router dont work.

routes

GET /login controllers.Application.login()
POST /login controllers.Application.authenticate()


Crontroller

package controllers;

import play.data.*;
import play.mvc.*;
import views.html.login;


public class Application extends Controller {

public static Result login() {
return ok(
login.render(
Form.form(Login.class)
)
);
}

public static Result authenticate() {
Form<Login> loginForm = Form.form(Login.class).bindFromRequest();
return ok();
}

}


The Result

Output

I use intellij

Has anyone experienced this?

Answer

In version 3.x of Play Framework, does not exists method static for actions.

Replace for:

package controllers;

import play.data.*;
import play.mvc.*;
import views.html.login;


public class Application extends Controller {

    public Result login() {
        return ok(
            login.render(
                Form.form(Login.class)
            )
        );
    }

    public Result authenticate() {
        Form<Login> loginForm = Form.form(Login.class).bindFromRequest();
        return ok();
    }

}