我試圖做一個特定的靜態文件的路由,但我試圖結束一個錯誤。路線到Play中的靜態文件! 2.0
我做了3次不同的嘗試:
1.
GET /file staticFile:/public/html/file.html
的錯誤,我得到:
Compilation error
string matching regex `\z' expected but `:' found
2.
GET /file controllers.Assets.at(path="/public/html", "file.html")
我得到的錯誤:
Compilation error
Identifier expected
3.
GET /file controllers.Assets.at(path="/public/html", file="file.html")
我得到的錯誤:(這是最古怪的)
Compilation error
not enough arguments for method at: (path: String, file: String)play.api.mvc.Call. Unspecified value parameter file.
關於第三個錯誤怪異的部分是,它是在一個不同的文件拋出( app/views/main.scala.html)在以下行上:
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
所有這些e方法在官方文檔和/或線程中發現在stackoverflow上。 我在這裏錯過了什麼?
謝謝。
我認爲第三個錯誤發生在默認模板中提到公共路由的第一個實例。我有完全相同的問題。我期望你/我嘗試添加靜態鏈接會擾亂反向路由。 – flurdy 2012-03-31 19:14:46
什麼?兩年,沒有被接受的答案。這個問題解決了嗎? – Jus12 2014-10-05 16:19:14
@ Jus12對不起,這只是我沒有繼續使用遊戲(不是我的選擇,這是不幸的),我不知道哪個答案是正確的。那個得票最多的人當時沒有解決問題(正如我的評論所解釋的)。如果有人會讓我知道任何答案是否正確,我會很樂意將其標記爲已接受。 – 2014-10-05 17:10:08