也許tomcat如此這般設計,是為了給我們留下更大的Diy空間吧。在web.xml中我們可以任意揮灑我們的創(chuàng )造能力,show出自己的個(gè)性。
我們最好在web.xml 中定義出最常見(jiàn)的一些錯誤,這樣可以保持網(wǎng)站的神秘性,讓別人看不出你的網(wǎng)站具體實(shí)現細節;),當然是為了安全考慮了。同時(shí),也是為了維護網(wǎng)站的尊嚴,不能xyzp.net天天顯示一些讓人討厭的錯誤頁(yè)面吧。
下面是實(shí)際定義的內容:
<error-page>
<error-code>404</error-code>
<location>/error/404.htm</location>
</error-page>
<error-page>
<error-code>400</error-code>
<location>/error/400.htm</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error/500.htm</location>
</error-page>
<error-page>
<error-code>503</error-code>
<location>/error/503.htm</location>
</error-page>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/error/500.htm</location>
</error-page>
<error-page>
<exception-type>java.lang.NullPointerException</exception-type>
<location>/error/500.htm</location>
</error-page>
定義好這些,發(fā)揮自己的想象力,下面我設計的錯誤頁(yè)面:
×××××××××××××××××××××××××××××××××××××××××××××××
聯(lián)系客服