【发布时间】:2018-11-26 06:03:54
【问题描述】:
我正在尝试找出一种方法来呈现或路由到托管在 Play 的公共文件夹中的一些静态 Web 应用程序。我的项目结构如下:
myapp
+ app
+ conf
+ modules
+ public
| + webapp1
| + css
| + images
| + index.html
| + webapp2
| + css
| + images
| + index.html
+ ...
我想渲染 webapp1 和 webapp2。每个 web 应用中的 index.html 将使用每个 web 应用中 css 文件夹中的 css 文件。
我尝试使用这样的路由并在控制器中使用重定向来呈现静态 html 页面:
Redirect("/webapp1/").withCookies(Cookie("token", "")).bakeCookies()
Redirect("/webapp2/").withCookies(Cookie("token", "")).bakeCookies()
GET /webapp1/ controllers.Assets.at(path="/public/webapp1", file="index.html")
GET /webapp1/*file controllers.Assets.at(path="/public/webapp1", file)
GET /webapp2/ controllers.Assets.at(path="/public/webapp2", file="index.html")
GET /webapp2/*file controllers.Assets.at(path="/public/webapp2", file)
index.html 将被正确路由和呈现。但是,文件夹中的 css 和图像未正确加载。 index.html 使用相对路径加载它们。然后以某种方式在 localhost/css/css1 等顶层加载 css 和图像,而不是 localhost/webapp1/css/css1。
建议将不胜感激。
比尔
【问题讨论】:
标签: html css playframework