Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Play Framework-值登录不是Controller.Application的成员_Java_Playframework - Fatal编程技术网

Java Play Framework-值登录不是Controller.Application的成员

Java Play Framework-值登录不是Controller.Application的成员,java,playframework,Java,Playframework,我正在运行最新的Play Framework 2.5.1,我的登录页面出现错误: 错误: value login is not a member of controllers.Application 我已尝试添加@符号,即: @controllers.Application.login() 并从build.sbt中删除喷油器,清理/清除“CMD”中的文件和更新。我用的是来自中国的样品 HTML代码 @(form: Form[Application.Login]) <html>

我正在运行最新的Play Framework 2.5.1,我的登录页面出现错误:

错误:

value login is not a member of controllers.Application
我已尝试添加
@
符号,即:

@controllers.Application.login()
并从
build.sbt
中删除喷油器,清理/清除“CMD”中的文件和更新。我用的是来自中国的样品

HTML代码

@(form: Form[Application.Login])
<html>
    <head>
        <title>Zentasks</title>
        <link rel="shortcut icon" type="image/png" href="@routes.Assets.versioned("images/favicon.png")">
        <link rel="stylesheet" type="text/css" media="screen" href="@routes.Assets.versioned("stylesheets/login.css")">
    </head>
    <body>
        <header>
            <a href=@routes.Application.index" id="logo"><span>Zen</span>tasks</a>
        </header>

    </body>
</html>
路线

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

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

GET     /login                      controllers.Application.login()

# Map static resources from the /public folder to the /assets URL path
GET     /assets/*file               @controllers.Assets.versioned(path="/public", file: Asset)

从控制器的操作中删除
static
关键字。Play 2.5.1默认情况下使用依赖项注入,如果您想使用
静态
操作,则需要。因此,您的登录操作必须如下所示:

// no static keyword here
public Result login() {
    return ok(login.render(form(Login.class)));
}
更新: 顺便说一下,你在这里混合了很多东西。我建议您在为2.5.x版开发时不要遵循2.1.0指南,因为这两个版本之间有很多差异。事实上,播放2.1.0是从2013年2月6日开始的

以下是一些说明代码失败原因的参考资料:

  • 在您目前使用2.5.x框架的2.1.x教程时,请看一下这里的文档。
    // no static keyword here
    public Result login() {
        return ok(login.render(form(Login.class)));
    }