我对 Play 2.0 相当陌生 - 我尝试搜索示例,但总是继续获取 Scala 模板作为将内容定向到的视图,是否可以仅使用非基于 Scala 的纯 html 文件作为视图?您如何要求控制器的操作方法将其定向到该 html 文件?
问问题
4277 次
1 回答
14
首先,将您的 HTML 文件放入public
文件夹中,例如:
public
|
├── html
|
└── hello.html
然后您可以使用Assets 控制器使用多种方式提供静态 HTML 文件:
通过直接在 URL 中引用文件:http://localhost:9000/assets/html/hello.html
通过使用该routes
文件将 URL 映射到您的文件。在routes
文件中,添加:
GET /hello controllers.Assets.at(path="/public", file="html/hello.html")
然后使用http://localhost:9000/hello
于 2013-08-02T08:24:23.987 回答