123456789101112131415161718 |
- package com.sf.conroller;
- import org.springframework.web.bind.annotation.ControllerAdvice;
- import org.springframework.web.bind.annotation.ExceptionHandler;
- import org.springframework.web.servlet.ModelAndView;
- @ControllerAdvice
- public class CommonException {
- @ExceptionHandler(value = {Exception.class})
- public ModelAndView testException(Exception e){
- System.out.println("error--->"+e.getMessage());
- ModelAndView modelAndView = new ModelAndView();
- modelAndView.setViewName("error");
- modelAndView.addObject("msg",e.getMessage());
- return modelAndView;
- }
- }
|