【发布时间】:2015-12-07 13:27:28
【问题描述】:
您好,我想从控制器提供我的 index.html 页面。而且我不希望它是一个视图,我希望它是一个纯 html 文件,我不需要播放模板引擎。
考虑以下几点:
路线:GET / controllers.MainApp.index
而路由实现是:
def index = Action { implicit request => if (AuthenticatedAction.isAuthenticated) { Ok(controllers.Assets.at(path="/public/", file="index.html")) } else Redirect(controllers.routes.Authentication.login()) }
我收到以下错误:
Cannot write an instance of play.api.mvc.Action[play.api.mvc.AnyContent] to HTTP response. Try to define a Writeable[play.api.mvc.Action[play.api.mvc.AnyContent]]
有没有办法提供这样的 html 页面?
一个可能的解决方案是这样做:
路线:GET /*file controllers.Assets.versioned(path="/public", file: Asset)
然后从控制器返回:
Redirect("/index.html")
这给了我一个我不想要的 url 路径:
http://localhost:9000/index.html#/
谢谢
【问题讨论】:
标签: html scala playframework