【问题标题】:Play Framework/ Eclipse/ Action not foundPlay Framework/ Eclipse/ Action not found
【发布时间】:2013-11-20 05:09:48
【问题描述】:

您好,我是 Play Framework 的新手,到现在为止的体验真的很糟糕。我观看或做的每个教程都会遇到一些无法修复的愚蠢错误。我离离开这个游戏框架只有一步之遥。无论如何,这是我得到的最后一个错误:

如果我去 localhost:9000/example 我得到这个错误

未找到操作 对于请求 '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

【问题讨论】:

    标签: java eclipse scala


    【解决方案1】:

    您需要像这样在路由文件中删除资源名称末尾的斜杠

    GET     /example                   controllers.Application.example()
    

    【讨论】:

    • 不知何故我知道,最后那是非常愚蠢的事情。非常感谢!
    猜你喜欢
    • 2016-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-02
    • 2023-03-31
    • 2021-04-16
    • 2021-10-25
    • 1970-01-01
    相关资源
    最近更新 更多