I get the following error:
org.springframework.web.util.NestedServletException: request processing failed; The nested exception is java.lang.NullPointerException
And to handle this in the controller, I used the following code:
@ExceptionHandler(NestedServletException.class)
public ModelAndView handleServletErrors(){
System.out.println("Servlet Exception is thrown");
ModelAndView mv = new ModelAndView("error");
mv.addObject("error", "Error encountered while processing reqeust.");
return mv;
}
But this does not handle the exception mentioned above. If I use the NullPointerException
class instead NestedServletException
, it works. Since Spring throws an exception in response to NullPointerException
, shouldn't it be handled using the code above?
source
share