1. 程式人生 > >web程式出現異常時實現頁面跳轉

web程式出現異常時實現頁面跳轉

在web.xml配置檔案下配置跳轉頁面

<!-- 異常跳轉頁面 -->
    <error-page>    
        <error-code>403</error-code>    
        <location>/error-404.html</location>    
    </error-page>    
    <error-page>    
        <error-code>404</error-code>    
        <location
>
/error-404.html</location> </error-page> <error-page> <error-code>405</error-code> <location>/error-404.html</location> </error-page> <error-page> <error-code>500</error-code>
<location>/error-404.html</location> </error-page> <error-page> <!--也可以指定異常型別(空指標等)--> <exception-type>java.lang.Exception</exception-type> <location>/error-404.html</location> </error-page>