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>

上面配置了当系统发生500错误(即服务器内部错误)时,跳转到错误处理页面error.jsp

 

二.   通过异常的类型配置error-page

Eg.

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

上面配置了当系统发生java.lang.NullException(即空指针异常)时,跳转到错误处理页面error.jsp
posted on 2007-06-08 15:26 阿蜜果 阅读(20725) 评论(10)  编辑  收藏 所属分类: Web


FeedBack:
# re: 在web.xml中配置error-page
2007-09-15 16:25 | gogo
error.jsp 是哪个目录下的 就是这个项目下的还是Root 下的
  回复  更多评论
  
# re: 在web.xml中配置error-page
2007-10-08 17:29 | hucarrot
谢谢  回复  更多评论
  
# re: 在web.xml中配置error-page
2008-03-11 02:12 | 路人甲
上面配置了当系统发生java.lang.NullException(即空指针异常)时,跳转到错误处理页面error.jsp

是java.lang.NullPointerException吧?  回复  更多评论
  
# re: 在web.xml中配置error-page
2008-10-30 15:00 | mingpi
项目下的。  回复  更多评论
  
# re: 在web.xml中配置error-page
2008-12-02 19:44 | xiaohe_mr
<error-code>和 <exception-type>二选一,不能在同一个<error-page>上同时出现  回复  更多评论
  
# re: 在web.xml中配置error-page
2009-01-15 20:43 | 暗暗暗暗
为什么我这样配置不行呢 我用了第一个  回复  更多评论
  
# re: 在web.xml中配置error-page
2009-03-15 10:59 | zhp
必须指定isErrorPage="true"  回复  更多评论
  
# 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>  回复  更多评论
  
# 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>   回复  更多评论
  
# re: 在web.xml中配置error-page[未登录]
2014-08-29 15:10 | sonic
必须是struts项目吗,纯spring mvc行吗  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 
<2007年6月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

      生活将我们磨圆,是为了让我们滚得更远——“圆”来如此。
      我的作品:
      玩转Axure RP  (2015年12月出版)
      

      Power Designer系统分析与建模实战  (2015年7月出版)
      
     Struts2+Hibernate3+Spring2   (2010年5月出版)
     

留言簿(262)

随笔分类

随笔档案

文章分类

相册

关注blog

积分与排名

  • 积分 - 2280199
  • 排名 - 3

最新评论

阅读排行榜

评论排行榜