web.xml配置詳解之歡迎頁面和錯誤頁面


<!-- 應用的歡迎頁面  采用list的方式羅列歡迎頁面,

系統會從第一個找到最后一個,找到了文件就不繼續往下找了。優先顯示前邊的。

-->

    <welcome-file-list>

       <welcome-file>index.jsp</welcome-file>

       <welcome-file>login.jsp</welcome-file>

       <welcome-file>index.html</welcome-file>

       <welcome-file>index.htm</welcome-file>

       <welcome-file>default.html</welcome-file>

       <welcome-file>default.htm</welcome-file>

       <welcome-file>default.jsp</welcome-file>

    </welcome-file-list>

    <!-- 通過上邊welcome-file-lis的配置:我們的應用的歡迎界面或者叫默認界面就是index.jsp,如果index.jsp沒找到的話

    就接着往下找:login.jsp,index.html.... -->

   

    <!-- 配置錯誤頁面

       error-page標簽用來配置檔應用出現指定錯誤碼的錯誤時候,有哪個頁面來處理這個錯誤,而不是給用戶

           顯示系統的錯誤信息。子標簽:

       error-code:系統錯誤碼

       location:應用系統中的處理錯誤頁面。

    -->

    <error-page>

       <error-code>404</error-code>

       <location>/common/404.html</location>

       <!-- 表示當系統發生404就是不存在請求地址的錯誤的時候,頁面跳轉到404.html頁面。 -->

    </error-page>

    <error-page>

       <error-code>500</error-code>

       <location>/common/error.jsp</location>

       <!-- 表示當系統發生500也就是操作異常錯誤的時候,頁面跳轉到error.jsp頁面。 -->

    </error-page>

    <error-page>

       <exception-type>java.lang.NullPointerException</exception-type>

       <location>/common/error.jsp</location>

       <!-- 表示當系統發生空指針異常錯誤的時候,頁面跳轉到error.html頁面。 -->

    </error-page>

    <!-- 通過上邊對error-apge的配置:當我們系統的系統發生404錯誤的時候,頁面調准到404.html,

    當頁面發生服務器錯我或者空指針錯誤的時候,頁面跳轉到error.html -->

</web-app>

 此文轉載於:http://angrycoder.iteye.com/blog/919375


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM