Spring MVC Exception Handling-Exceptionhandler

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.