I'm using Spring 3.2.0. I have implemented the resolveException() method in my annotated controller which implements the HandlerExceptionResolver interface such as,
and the Spring configuration includes,Code:@Controller public final class ProductImageController implements HandlerExceptionResolver { public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception exception) { Map<String, Object> model = new HashMap<String, Object>(0); if(exception instanceof MaxUploadSizeExceededException) { model.put("msg", exception.toString()); model.put("status", "-1"); } else { model.put("msg", "Unexpected error : "+exception.toString()); model.put("status", "-1"); } return new ModelAndView("admin_side/ProductImage"); } }
as specified here.Code:<bean id="filterMultipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize"> <value>10000</value> </property> </bean>
When the file size exceeds, the method in the controller class should be invoked and it should automatically handle the exception but it doesn't happen at all. What I'm getting is the full stack trace on the browser. The method resolveException() is never called even though the exception occurs. What is the way to handle this exception? Am I missing something?
I have also tried registering a separate bean annotated with @Component in application-context.xml but nothing worked.


Reply With Quote