簡體   English   中英

將404重定向到servlet應用外部的頁面

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM