您好我是Play Framework的新手,直到现在经验非常糟糕。我观看或做的每个教程都会遇到一些我无法解决的愚蠢错误。我离开这个游戏框架只有一步之遥。无论如何这是我的最后一次错误:
如果我去localhost:9000 /例子我会收到此错误
未找到操作 对于请求'GET / example' 已经按以下顺序尝试了这些路线:
1GET/controllers.Application.index()
2GET/example/controllers.Application.example()
3GET/assets/$file<.+>controllers.Assets.at(path:String = "/public", file:String)
我的Application.java看起来像这样:
package controllers;
import play.*;
import play.mvc.*;
import views.html.*;
public class Application extends Controller {
public static Result index() {
return ok(index.render("Play Tutorial :)"));
}
public static Result example(){
String s = "Hello Mr View";
return ok(fun.render(s));
}
}
这是我的路线档案:
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index()
GET /example/ controllers.Application.example()
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
这是我的fun.scala.html文件:
@(message: String)
<h1>@message</h1>
我在本教程中这样做: http://www.youtube.com/watch?v=mST2YmQYgS8&list=PL177265F762D05F72
答案 0 :(得分:0)
您需要在路径文件中的资源名称末尾删除斜杠
GET /example controllers.Application.example()