Harman opened SPR-7586 and commented
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
Quote:
@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;
}
Affects: 3.0.2
Reference URL: http://forum.springsource.org/showthread.php?p=320611#post320611