When I using spring exception handler based on controlleruse @ExceptionHandler within Controller, it's not working as expected.
Here is my code is here:
@Controller public class PageController { @RequestMapping("/page") public ModelAndView index(ModelAndView modelAndView){ String mess = null; mess.split(","); modelAndView.setViewName("index"); return modelAndView; } @ExceptionHandler({Exception.class}) @ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "Bad Request") public ModelAndView handleException(Exception ex, HttpServletRequest request, HttpServletResponse response){ ModelAndView modelAndView = new ModelAndView(); modelAndView.addObject("message", ex.getMessage()); modelAndView.addObject("url", request.getRequestURL()); modelAndView.addObject("code", response.getStatus()); modelAndView.setViewName("exception"); return modelAndView; } } afterAfter the application startedstarts with debug mode, I visit http://localhost:8080/pagehttp://localhost:8080/page, and handleException has beenhandleException is running, but the view is below other than the expected excepction view.Why Why? 
