[英]Play Framework 2.3.x external asset / upload folder
我是玩框架的新手-(Java版本)。 我們正在移植一個舊應用程序,該應用程序從不同位置使用資產文件夾。 說...
資產位置:
/home/user/other/asset/location/upload
比賽地點
/home/user/some/play/location
在路由文件中,有...
GET /assets/*file controllers.Assets.at(path="/public", file)
GET /upload/*file controllers.Assets.at(path="/home/user/other/asset/location/upload", file)
在(SBT)build.sbt文件中...
unmanagedResourceDirectories in Assets += baseDirectory.value / "/home/user/other/asset/location/upload"
我正在這樣使用...
public class AssetHelper
{
public static final String ASSET = "/public";
public static final String UPLOAD = "/home/user/other/asset/location/upload";
}
在用戶個人資料視圖中...
<img src="@routes.Assets.at(AssetHelper.UPLOAD,"userprofile/12345/profilepic/imgo.jpeg")" alt="SomeImage"/>
普通的CSS和JavaScript ...
<img class="logo" src="@routes.Assets.at(AssetHelper.ASSET,"dist/css/images/logo.png")" alt="LOGO">
我想包括其他位置資產,該怎么做? 您可以解釋build.sbt的給定參數,因為還不知道scala嗎?
Play Framework核心的資產控制器只能提供捆綁在應用程序jar中的文件。 如果要從文件系統返回靜態文件,則必須編寫自己的控制器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.