当前位置:编程学习 > XML/UML >>

web.xml定义错误或异常页面的友好界面显示

[html]
<error-page> 
    <error-code>403</error-code> 
    <location>/noPermission.jsp</location> 
</error-page> 
<error-page> 
    <error-code>404</error-code> 
    <location>/noFound.jsp</location> 
</error-page> 
<error-page> 
    <error-code>500</error-code> 
    <location>/serverError.jsp</location> 
</error-page> 
 
<!-- java.lang.Exception异常错误,依据这个标记可定义多个类似错误提示 --> 
  
<error-page> 
    <exception-type>java.lang.Exception</exception-type> 
    <location>/serverError.jsp</location> 
</error-page> 
 
<!-- java.lang.NullPointerException异常错误,依据这个标记可定义多个类似错误提示 --> 
  
<error-page> 
    <exception-type>java.lang.NullPointerException</exception-type> 
    <location>/serverError.jsp</location> 
</error-page> 
<error-page> 
    <exception-type>javax.servlet.ServletException</exception-type> 
    <location>/serverError.jsp</location> 
</error-page> 

 
 <error-page>
  <error-code>403</error-code>
  <location>/noPermission.jsp</location>
 </error-page>
 <error-page>
  <error-code>404</error-code>
  <location>/noFound.jsp</location>
 </error-page>
 <error-page>
  <error-code>500</error-code>
  <location>/serverError.jsp</location>
 </error-page>

 <!-- java.lang.Exception异常错误,依据这个标记可定义多个类似错误提示 -->
 
 <error-page>
  <exception-type>java.lang.Exception</exception-type>
  <location>/serverError.jsp</location>
 </error-page>
 
 <!-- java.lang.NullPointerException异常错误,依据这个标记可定义多个类似错误提示 -->
 
 <error-page>
  <exception-type>java.lang.NullPointerException</exception-type>
  <location>/serverError.jsp</location>
 </error-page>
 <error-page>
  <exception-type>javax.servlet.ServletException</exception-type>
  <location>/serverError.jsp</location>
 </error-page>
 


 

补充:web前端 , HTML/CSS  ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,