Handler exceptions through Handlerexceptionresolver, including handler mappings, data binding, and exceptions that occur when the target method executes
The implementation class is as follows
/** 1. A parameter of type Exception can be added to the input parameter of the @ExceptionHandler method, which corresponds to the exception object that occurred * 2. You cannot pass in a Map in the input of a @ExceptionHandler method. Look for the exception information to be transmitted on the page, you need to use Modelandview as the return value * 3. The exception that is flagged by the @ExceptionHandler method has a priority problem. * 4. @ControllerAdvice: If the @ExceptionHandler method is not found in the current Handler to come out of the exception that appears in the current method, the * will be found in the class @ControllerAdvice tag @ExceptionHan Dler The marked method to handle the exception. */@ExceptionHandler ({arithmeticexception.class}) PublicModelandview handlearithmeticexception (Exception ex) {System. out. println ("out of the ordinary:"+ex); Modelandview MV=NewModelandview ("Error"); Mv.addobject ("Exception", ex); returnMV; }
Spring MVC Exception Handling-Exceptionhandler