简体   繁体   中英

How to add routes in a Play Framework 2.5.x?

I am very new in Play framework. I am planning to add a very simple route. But it keeps saying that Action not found.

It works only for the index.

Action not found:

在此处输入图片说明

My Application.java:

public class Application extends Controller {

    public Result index() {
        return ok(index.render());
    }

    public Result home() {
        return ok(home.render());
    }  

}

The routes configuration file:

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~


# Landing page
GET        /                                 controllers.Application.index()


GET         /home                            controllers.Application.home()


# Map the JS resource paths
GET        /*file                            controllers.Assets.versioned(path="/public", file: Asset)

Tried activator clean compile , but still it does not work.

So here is how I fixed it.

# Landing page
GET        /                                 controllers.Application.index()

#After entering username and password
GET         /home                                   controllers.Application.home()

Added a comment before the route command. It's weird, very weird.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM