在<%@page 中  有個errorPage 可以設定若是error時會導致此網頁

Ex:

假設 <%@page errorPage="exerror.jsp"   %>

則 exeeor.jsp頁面

如果也確定為error頁面時  則其<%page 中的 isErrorPage要為true

 

 顯示錯誤相關訊息則要用 exception

Ex

<%= exception %>

 若是要知道完整的錯誤內容則是:

<%
exception.printStackTrace(new PrintWriter(out));
%>

 但記得要import  PrintWriter

<%@page import="java.io.PrintWriter"%>

 

 若要設定在web.xml內則:

<web-app>

    <error-page>

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

         <location>/exerror.jsp</location>

    </error-page>

</web-app>

 

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 JoshS 的頭像
    JoshS

    JoshS的部落格

    JoshS 發表在 痞客邦 留言(0) 人氣()