In my application I have configured an error page in web.xml. I need to override that for a specific controller based on a condition. Here when a condition becomes true I need to redirect to a specific error page otherwise normal error page should be rendered. Here is the code. Please help me.
@Controller public class Test{ @ExceptionHandler(Exception.class) public ModelAndView generateException(HttpServletRequest httpServletRequest){ if(condition) { return new ModelAndView("myError.jsp"); } else { //should execute default error page. } } }