Hi,
I am using Spring Rest to process JSON request and return a JSON response, all works fine.
Now i want to return a html view to user in case JSON request processing throws an exception. For this i have used @ExceptionHandler to create a ModelAndView, but after returning the response DispatcherServlet uses MappingJacksonView to render the response.
Is there a way i can render a HTML Page( in case of error) for request with accept header as application/json
@ExceptionHanlder(value=MultipleItemsFoundExceptio n.class
public ModelAndView handleMultipleItemError(MultipleItemsFoundExceptio n e, HttpServletResponse response){
ModelAndView mav = new ModelAndView();
mav.setViewName("detail");
mav.addObject("list",e.getItemList());
response.setContentType("text/html");
return mav;
}


Reply With Quote
