繁体   English   中英

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

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

我在Play框架中非常陌生。 我计划添加一条非常简单的路线。 但是它一直说没有找到动作。

它仅适用于索引。

找不到动作:

在此处输入图片说明

我的Application.java:

public class Application extends Controller {

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

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

}

路由配置文件:

# 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)

尝试过使用activator clean compile ,但仍然无法正常工作。

所以这是我修复它的方法。

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

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

在route命令之前添加了注释。 这很奇怪,很奇怪。

暂无
暂无

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

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