我將我們的應用程序從Play 2.3.x遷移到2.4.x.隨着遠離靜態路由遷移,我顯然失去了重定向到某些資產的能力。該應用程序實現了可附加到url(localhost:9000/Tenant /)的租戶功能,該功能會將您重定向到帶有在後臺設置的相應租戶的登錄頁面。通過使用url的附錄(localhost:9000 /),可以訪問默認租戶(用於開發目的)。播放框架資產路由在版本2.4.x中不起作用
現在,設置承租人後,我重定向到應用程序/ index.html的使用下面的問題:
return redirect(query != null ? "app/index.html?" + query : "app/index.html");
重定向作品,但不幸的是我得到「找不到動作 的請求「GET /app/index.html'」。如果手動重定向,我也無法訪問資產。
在應用程序的路徑文件中,以下路徑條目應該正確處理此重定向,我錯了嗎?
# Map static resources from the /public/app folder to the /app URL path
GET /app/*file controllers.Assets.at(path="/public/app", file)
日誌遺憾的是並沒有說什麼特別的,除了:
**** [TRACE] Http request received by netty: DefaultHttpRequest(chunked: false)
**** GET /app/index.html HTTP/1.1
**** Host: localhost:9000
**** Connection: keep-alive
**** Upgrade-Insecure-Requests: 1
**** User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
**** Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
**** Accept-Encoding: gzip, deflate, sdch
**** Accept-Language: en-US,en;q=0.8,de;q=0.6
**** Cookie: PLAY_SESSION="f2069c9ef539f8d3fe9d07327a3c65bd4a45cb79-MANDT=0B7ABE451F3441A5AB93799DBC8621EF" [play.core.server.netty.PlayDefaultUpstreamHandler]
**** [TRACE] Serving this request with: <function1> [play.core.server.netty.PlayDefaultUpstreamHandler]
**** [TRACE] Invoking action with request: GET /app/index.html [play.api.mvc.Action]
我在其他情況下看到[Play Framework Routes not working],人們已經接受在控制檯上的錯誤表示該路由已經試過了。
這工作在2.3.x,但在2.4.x沒有了。我錯過了什麼?
重定向時只有這個問題? (也就是說,如果你直接在瀏覽器中訪問/app/index.html,它可以工作嗎?) – Salem
'GET/app/* files controllers.Assets.at(path =「/ public」,file)' 你可以試試這個你檢查'重定向'可以處理1行,如果語句? –
@Salem:問題不僅在於重定向,它似乎與每次調用index.html。 – Ben