简体   繁体   English

Play Framework Routes无效

[英]Play Framework Routes not working

I am just trying to follow along with the ZenTasks tutorial ( http://www.playframework.com/documentation/2.1.0/JavaGuide4 ) for the Play Framework. 我只是想跟随Play框架的ZenTasks教程( http://www.playframework.com/documentation/2.1.0/JavaGuide4 )。 I can't seem to even get the Login page to work however. 我似乎无法让登录页面工作。

I am running this project with the play ~run command. 我正在使用play ~run命令运行这个项目。 When navigating to http://localhost:9000/login the error is 导航到http://localhost:9000/login出错

Action not found For request 'GET /login'
These routes have been tried, in this order:
1 GET/controllers.Application.index()
2 GET/assets/$file<.+>controllers.Assets.at(path:String = "/public", file:String)`

My routes file looks like 我的路线文件看起来像

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

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

# User athentication
GET     /login                      controllers.Application.login()
POST    /login                      controllers.Application.authenticate()
GET     /logout                     controllers.Application.logout()

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

and the Application.login, authenticate, and logout functions all compile properly. 并且Application.login,authenticate和logout函数都可以正确编译。 Am I missing something incredibly easy here, because I can't tell what is going wrong? 我在这里错过了一些非常容易的东西,因为我不知道出了什么问题?

Looks like the routes file wasn't compiled properly. 看起来路由文件未正确编译。 probably, you should do a clean in the play console and try again 可能,你应该在游戏机上做一个干净,然后再试一次

$ play clean-all

@DiAlex @DiAlex

Just in case play clean-all doesn't work, you can try to 为了防止play clean-all都行不通,你可以尝试

$ clean 

then 然后

$ compile

within the play console. 在播放控制台内。

However, I think both of them do the same thing. 但是,我认为他们都做同样的事情。

If you are using play framework via Activator you can simply do the follow steps: 如果您通过Activator使用Play框架,则只需执行以下步骤:

  1. sbt clean 干净
  2. activator run 激活运行

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

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