Would like to ask you a best practice question where a spring-mvc controller is concerned. Please review the code below:
@Autowired
SomeService service;
Define bean in bean definition file for Handler class. when any exception is thrown in a program ,resolveException method is called.
public class Handler
implements HandlerExceptionResolver
{
public Handler()
{
}
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
{
if(ex instanceof ErrorType1Exception))
{
ModelAndView test = new ModelAndView("errorpage1jsppage");
return test;
} else
if(ex instanceof ErrorType2Exception))
{
ModelAndView test1 = new ModelAndView("errorpage2jsppage");
return test1
}
}
}