Java – play framework 2.4 does not accept “public static results” from controllers

I try to start the application using play framework 2.4 and JDK 8 in MAC when I use/ When the activator downloads the foundation, a new project is played - the Java template code contains the following:

Project / application / controls / application java

package controllers;

import play.*;
import play.mvc.*;

import views.html.*;

public class Application extends Controller {

    public Result index() {
        return ok(index.render("Your new application is ready."));
    }

}

But when I replace this part:

public static Result index() {...

Add "static" to index()

I received this error

Compilation error
value index is not a member of controllers.Application
.../conf/routes:6
4 # ~~~~
5 # Home page
6 GET     /                           controllers.Application.index()

I don't know why, because static for result is used in all examples

Solution

You may still be using legacy routing

From documentation:

Alternatively, you can stick to a static router (but if you're creating a new application, why?) And add before the action reference@

GET        /some/path        @controllers.Application.index()
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>