posts - 297,  comments - 1618,  trackbacks - 0
           

          我知道在web.xml中有兩種配置error-page的方法,一是通過錯誤碼來配置,而是通過異常的類型來配置,分別舉例如下:

          一.   通過錯誤碼來配置error-page

          Eg.

          <error-page>
                  <error-code>500</error-code>
                  <location>/error.jsp</location>
            </error-page>

          上面配置了當(dāng)系統(tǒng)發(fā)生500錯誤(即服務(wù)器內(nèi)部錯誤)時,跳轉(zhuǎn)到錯誤處理頁面error.jsp

           

          二.   通過異常的類型配置error-page

          Eg.

          <error-page>
                  <exception-type>java.lang.NullException</exception-type>
                  <location>/error.jsp</location>
             </error-page>

          上面配置了當(dāng)系統(tǒng)發(fā)生java.lang.NullException(即空指針異常)時,跳轉(zhuǎn)到錯誤處理頁面error.jsp
          posted on 2007-06-08 15:26 阿蜜果 閱讀(20822) 評論(10)  編輯  收藏 所屬分類: Web


          FeedBack:
          # re: 在web.xml中配置error-page
          2007-09-15 16:25 | gogo
          error.jsp 是哪個目錄下的 就是這個項(xiàng)目下的還是Root 下的
            回復(fù)  更多評論
            
          # re: 在web.xml中配置error-page
          2007-10-08 17:29 | hucarrot
          謝謝  回復(fù)  更多評論
            
          # re: 在web.xml中配置error-page
          2008-03-11 02:12 | 路人甲
          上面配置了當(dāng)系統(tǒng)發(fā)生java.lang.NullException(即空指針異常)時,跳轉(zhuǎn)到錯誤處理頁面error.jsp

          是java.lang.NullPointerException吧?  回復(fù)  更多評論
            
          # re: 在web.xml中配置error-page
          2008-10-30 15:00 | mingpi
          項(xiàng)目下的。  回復(fù)  更多評論
            
          # re: 在web.xml中配置error-page
          2008-12-02 19:44 | xiaohe_mr
          <error-code>和 <exception-type>二選一,不能在同一個<error-page>上同時出現(xiàn)  回復(fù)  更多評論
            
          # re: 在web.xml中配置error-page
          2009-01-15 20:43 | 暗暗暗暗
          為什么我這樣配置不行呢 我用了第一個  回復(fù)  更多評論
            
          # re: 在web.xml中配置error-page
          2009-03-15 10:59 | zhp
          必須指定isErrorPage="true"  回復(fù)  更多評論
            
          # re: 在web.xml中配置error-page
          2009-03-15 11:01 | zhp
          <%@ page contentType="text/html;charset=GB2312" isErrorPage="true"%>
          <%@ page import="java.io.PrintWriter"%>
          <html>
          <head>
          <title>error.jsp title</title>
          </head>
          <body>
          <h2>錯誤信息:</h2>
          <%= exception %>
          <br>

          <h2>問題如下:</h2><% exception.printStackTrace(new PrintWriter(out));%>
          <hr>

          </body>
          </html>  回復(fù)  更多評論
            
          # re: 在web.xml中配置error-page
          2009-03-15 11:02 | zhp
          <error-page>
          <error-code>500</error-code>
          <location>/error404.jsp</location>
          </error-page>
          <error-page>
          <exception-type>java.lang.Exception</exception-type>
          <location>/exception.jsp</location>
          </error-page>   回復(fù)  更多評論
            
          # re: 在web.xml中配置error-page[未登錄]
          2014-08-29 15:10 | sonic
          必須是struts項(xiàng)目嗎,純spring mvc行嗎  回復(fù)  更多評論
            
          <2007年6月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          1234567

                生活將我們磨圓,是為了讓我們滾得更遠(yuǎn)——“圓”來如此。
                我的作品:
                玩轉(zhuǎn)Axure RP  (2015年12月出版)
                

                Power Designer系統(tǒng)分析與建模實(shí)戰(zhàn)  (2015年7月出版)
                
               Struts2+Hibernate3+Spring2   (2010年5月出版)
               

          留言簿(263)

          隨筆分類

          隨筆檔案

          文章分類

          相冊

          關(guān)注blog

          積分與排名

          • 積分 - 2299173
          • 排名 - 3

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 安塞县| 凤山县| 塘沽区| 上栗县| 溆浦县| 胶南市| 洪雅县| 曲阳县| 开原市| 黄石市| 常宁市| 梁平县| 水城县| 宜君县| 青川县| 惠水县| 宝兴县| 蓬溪县| 宁津县| 九江县| 和林格尔县| 聂拉木县| 思南县| 宁陵县| 武强县| 岑溪市| 营口市| 富源县| 乌拉特前旗| 泗洪县| 灵川县| 印江| 吴堡县| 阳新县| 高台县| 大丰市| 丘北县| 温宿县| 互助| 汽车| 红桥区|