1

我已经定义了以下路由文件:

GET     /           controllers.Application.app

# web service entries...
GET     /api/users  controllers.Users.list
[...]

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

在我的 Application.app 操作中,我只是重定向到 index.html

def app = Action {
  Redirect(routes.Assets.at("index.html"))
}

所以当我访问我的应用程序时,http://mydomain我被重定向到http://mydoamin/index.html,然后将 /#ideas 添加到该位置(它是一个单一的网页应用程序)

我想摆脱 index.html 文件,而是被重定向到http://mydoamin/#ideas

是否可以?

4

2 回答 2

2

在您的路线文件中使用它:

GET     /     controllers.Assets.at(path="/public", file="index.html")

所以你不需要触摸任何控制器。

于 2012-10-15T08:21:37.347 回答
1

只是一个指针:您可以尝试从 Asset 控制器获取 Html 代码,然后返回带有 Html 内容的 Ok Result。

为此,您可以尝试查看在测试助手中如何调用控制器,以及如何获取此调用的 Result 和主体。

大致(未测试):

def app = Action {
    request => {
        val result = controllers.Assets.at("public","index.html")(request)
        val html = contentAsString(result)

        Ok(html)
    }
}
于 2012-10-15T08:11:11.393 回答