【发布时间】:2015-11-03 12:06:08
【问题描述】:
我将 main.scala.html 放在资产中。而且我想在不设置路由的情况下打开它,因为它是静态的。
在controllers.Application中,我试过这样
public static Result index() {
//return ok(index.render("Your new application is ready."));
return redirect("assets/main/main.scala.html");
}
在路线页面中,我尝试过这样
GET / controllers.Application.index
GET /*file controllers.Assets.at(path="/assets", file)
如何修复我的代码以打开http://localhost:9000/assets/main/main.scala.html?
或者我应该尝试将 html 文件放在公共文件夹中吗?
【问题讨论】:
-
我不会只是找到一种不同的方式来为用户提供静态内容。我建议通过在控制器中呈现模板和文件来坚持提供内容的通常方式,并且仍然为其添加路由。它更简单、更优雅。
-
感谢您的回复。我也喜欢通常的方式,但是想要培训我的老板让我将html文件放入资产中,因为我已经按照通常的方式制作了一个;_;
标签: java scala playframework