第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在web.xml中指定默認(rèn)錯誤頁面?

如何在web.xml中指定默認(rèn)錯誤頁面?

猛跑小豬 2019-07-23 19:23:39
如何在web.xml中指定默認(rèn)錯誤頁面?我<error-page>在web.xml中使用元素來指定用戶遇到某個錯誤時的友好錯誤頁面,例如代碼為404的錯誤:<error-page>         <error-code>404</error-code>         <location>/Error404.html</location></error-page>但是,我希望如果用戶不符合指定的任何錯誤代碼<error-page>,他或她應(yīng)該看到默認(rèn)錯誤頁面。如何使用web.xml中的元素執(zhí)行此操作?
查看完整描述

3 回答

?
拉莫斯之舞

TA貢獻(xiàn)1820條經(jīng)驗 獲得超10個贊

在Servlet 3.0或更高版本上,您可以指定

<web-app ...>
    <error-page>
        <location>/general-error.html</location>
    </error-page></web-app>

但是當(dāng)你仍然使用Servlet 2.5時,除了單獨指定每個常見的HTTP錯誤之外別無他法。您需要確定最終用戶可能面臨的HTTP錯誤。在一個準(zhǔn)系統(tǒng)webapp上,例如使用HTTP身份驗證,具有禁用的目錄列表,使用自定義servlet和代碼可能會拋出未處理的異常或者沒有實現(xiàn)所有方法,那么你想為HTTP錯誤設(shè)置它401分別為403,40和503。

<error-page>
    <!-- Missing login -->
    <error-code>401</error-code>
    <location>/general-error.html</location></error-page><error-page>
    <!-- Forbidden directory listing -->
    <error-code>403</error-code>
    <location>/general-error.html</location></error-page><error-page>
    <!-- Missing resource -->
    <error-code>404</error-code>
    <location>/Error404.html</location></error-page><error-page>
    <!-- Uncaught exception -->
    <error-code>500</error-code>
    <location>/general-error.html</location></error-page><error-page>
    <!-- Unsupported servlet method -->
    <error-code>503</error-code>
    <location>/general-error.html</location></error-page>

這應(yīng)該包括最常見的。


查看完整回答
反對 回復(fù) 2019-07-23
?
Helenr

TA貢獻(xiàn)1780條經(jīng)驗 獲得超4個贊

你也可以這樣做:

<error-page>
    <error-code>403</error-code>
    <location>/403.html</location></error-page><error-page>
    <location>/error.html</location></error-page>

對于錯誤代碼403,它將返回頁面403.html,對于任何其他錯誤代碼,它將返回頁面error.html。


查看完整回答
反對 回復(fù) 2019-07-23
?
弒天下

TA貢獻(xiàn)1818條經(jīng)驗 獲得超8個贊

您還可以<error-page>使用<exception-type>例如以下內(nèi)容指定例外:

<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/errorpages/exception.html</location></error-page>

或使用<error-code>以下內(nèi)容映射錯誤代碼:

<error-page>
    <error-code>404</error-code>
    <location>/errorpages/404error.html</location></error-page>


查看完整回答
反對 回復(fù) 2019-07-23
  • 3 回答
  • 0 關(guān)注
  • 1433 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號