[英]Redirecting 404s to a page outside the servlet app
我們在同一服務器上有多個servlet應用程序。 我們希望每個應用程序都轉發到服務器根目錄中的同一頁面,而不是每個應用程序都維護自己的自定義404頁面。 將這樣的配置添加到web.xml中不起作用:
<error-page>
<error-code>404</error-code>
<location>/someOtherApp/notFound.html</location>
</error-page>
它嘗試重定向到/myAppName/someOtherApp/notFound.html而不是/someOtherApp/notFound.html
有任何想法嗎?
在<error-page>
的location
元素中
<error-page>
<error-code>404</error-code>
<location>/someOtherApp/notFound.html</location>
</error-page>
路徑必須相對於應用程序的根目錄。 您不能使其由其他應用程序提供。
一些jetty
文檔在這里 。
Location
不重定向,它前進。 正如Sotirios Delimanolis指出的那樣。 它必須保留在webapp中(相對於)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.