Code example for ModelAndView

Methods: addAllObjectssetViewName

0
     * @return  The error page containing the appropriate message to the user.  
     */ 
    @Override 
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception exception) { 
        String message = ""; 
        ModelAndView modelAndView = new ModelAndView(); 
        Map<String, Object> model = new HashMap<String, Object>(); 
        modelAndView.setViewName("fatalError");  
        if (exception instanceof AccessDeniedException){  
            message = exception.getMessage(); 
            modelAndView.setViewName("denied"); 
        } else if (exception instanceof NullPointerException) { 
            message = "Problem with the tableStashDir argument during File creation.  Verify the wmotables.home value in the wmotables.properties file is correct: " + exception.getMessage(); 
        } else if (exception instanceof FileNotFoundException) { 
            message = "Unable to create FileOutputStream for File: " + exception.getMessage(); 
        } else if (exception instanceof IOException) { 
            message = "An IO error occured with the FileOutputStream for File: " + exception.getMessage(); 
        } else if (exception instanceof SecurityException) { 
            message = "JVM security manager configuration conflict.  Unable to write File: " + exception.getMessage(); 
        } else { 
            message = "An error has occurred: " + exception.getClass().getName() + ": " + exception.getMessage();   
        }         
        logger.error(message); 
        model.put("message", message); 
        modelAndView.addAllObjects(model); 
        return modelAndView; 
    } 
 
 
    /** 
Connect your IDE to all the code out there  Get Codota for Java