简体   繁体   English

如何在Play Framework 2.5.x中添加路由?

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

I am very new in Play framework. 我在Play框架中非常陌生。 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: 我的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. 尝试过使用activator clean compile ,但仍然无法正常工作。

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. 在route命令之前添加了注释。 It's weird, very weird. 这很奇怪,很奇怪。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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