我有一个奇怪的问题。我有一个用Play编写的应用程序!框架2.0.4。它使用一些公共资产(css / images / javascript)。当我在开发模式下运行时,一切都很好:
blus@vmblus:~/svn/blus> play
[info] Loading project definition from /home/blus/svn/blus/project/project
[info] Loading project definition from /home/blus/svn/blus/project
[info] Set current project to blus (in build file:/home/blus/svn/blus/)
_ _
_ __ | | __ _ _ _| |
| '_ \| |/ _' | || |_|
| __/|_|\____|\__ (_)
|_| |__/
play! 2.0.4, http://www.playframework.org
> Type "help play" or "license" for more information.
> Type "exit" or use Ctrl+D to leave this console.
[blus] $ run
--- (Running the application from SBT, auto-reloading is enabled) ---
[info] play - Listening for HTTP on port 9000...
(Server started, use Ctrl+D to stop and go back to the console...)
在浏览器中资产加载没有任何问题。但是,当我想在生产模式中运行相同的应用程序(未复制,未移动,只是相同)时,资产就消失了:
[blus] $ start 9000
(Starting server. Type Ctrl+D to exit logs, the server will remain in background)
Play server process ID is 6845
[info] play - Application started (Prod)
[info] play - Listening for HTTP on port 9000...
Firebug显示:
"NetworkError: 404 Not Found - http://vmblus:9000/assets/stylesheets/main.css"
找不到所有需要的资产。这怎么可能呢?我该怎么做才能解决这个问题?
这是我的conf/routes
:
GET /assets/*file controllers.ExternalAssets.at(path="public", file)
这就是我在观看中调用资产的方式:
<link rel="stylesheet" media="screen" href="@routes.ExternalAssets.at("stylesheets/main.css")">
我看到this question,但我的路径没有//
。
答案 0 :(得分:2)
您使用controllers.ExternalAssets.at
代替controllers.Assets.at
这很可能就是原因。