开发者

Web.xml ExceptionType

开发者 https://www.devze.com 2022-12-26 00:30 出处:网络
Is it possible to define two sections in the web.xml in order to 开发者_如何学编程catch two different exception types:

Is it possible to define two sections in the web.xml in order to 开发者_如何学编程catch two different exception types:

<!-- general exception -->
<error-page> 
  <exception-type>**java.lang.Exception**</exception-type> 
  <location>/generalError.jsp</location> 
</error-page>

<!-- specific exception -->
<error-page> 
  <exception-type>org.myapp.myException</exception-type> 
  <location>/sessionTimeout.jsp</location> 
</error-page>

Does this cause any conflict?


No, there is no conflict and it will work as intended. This is what the servlet spec 2.5 (9.9.2) says:

The closest match in the class hierarchy wins.

So myException (and its sub-classes) will use sessionTimeout.jsp, and all others generalError.jsp.

0

精彩评论

暂无评论...
验证码 换一张
取 消