Exception handling in Struts 2 and Hibernate

后端 未结 2 1300
逝去的感伤
逝去的感伤 2021-01-16 15:06

Suppose that we have developed a website in Struts2, Hibernate, MySQL and we have added few try/catch blocks here are there which encloses database calls via Hi

2条回答
  •  逝去的感伤
    2021-01-16 15:23

    Exceptions are the results of the program or developer can't handle the situation with abnormal behavior. In this case the developer could know that the exception is thrown and could make some actions toward resolving the case.

    The ordinary user doesn't need to know about any exception but the system administrators actually do. So, logging exceptions are good making the possibility to solve any problems further.

    This is also useful on the development stage, when the developer needs to debug the issue via printing stacktrace, rethrowing exception. Rarely applicable in this situation the catching and ignoring exceptions.

    In the normal situation exceptions should be caught, logged and rethrown. But in the Struts2 you could handle uncaught exceptions via creating the default application interceptor stack

    
      
        true
        ERROR
      
    
    

    any exceptions not caught by this application will be logged and then handled by the global exception mapping

    
      
    
    
    
      /error_page.jsp
    
    

提交回复
热议问题