在Playframework2中,如何为多个资产目录提供服务? [英] In Playframework2, how to serve multiple asset directory?
本文介绍了在Playframework2中,如何为多个资产目录提供服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有两个资产目录,一个是/ui/dist
,另一个是/public
.我试图这样写路线:
There are two asset directory, one is /ui/dist
and the other is /public
. I tried to write the routes like this:
GET /assets/*file controllers.Assets.at(path="/public", file)
GET /ui/*file controllers.Assets.at(path="/ui/dist", file)
但是编译时会抛出错误:
But it will throws an error while compiling:
[error] Unspecified value parameter file.
[error] <link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
有人对如何解决这个问题有想法吗?
Does anyone have ideas about how to solve this...
推荐答案
我发现关键是将另一个参数传递给routes.Assets.at
,以下内容来自playframework
I found the key is to pass in another parameter to routes.Assets.at
, the following is from the playframework Asset document
GET /javascripts/*file Assets.at("public/javascripts", file)
GET /images/*file Assets.at("public/images", file)
然后,当您使用反向路由器时,您将需要指定两个参数:
Then you will need to specify both parameters when using the reverse router:
<script src="@routes.Assets.at("public/javascripts", "jquery.js")"></script>
<image src="@routes.Assets.at("public/images", "logo.png")">
这篇关于在Playframework2中,如何为多个资产目录提供服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文