views:

13

answers:

1

Hi All,

I am having trouble with catching and gracefully handling commons fileupload's FileUploadBase.SizeLimitExceededException or spring's MaxUploadSizeExceededException when uploading large files.

From what I can tell these exceptions are thrown during data binding, before the controller is actually reached, therefore resulting in a 500 and no calling of the exception handler method. Has anyone come across this before, and what is the best way for handling these exceptions properly?

Thanks in advance,
Luke

A: 

This seems to be a quite common problem. I've had similar problems and similar questions have been asked, see for example this question. I have yet to see a nice solution to the problem. You could use a vanilla servlet filter to handle these exceptions, but that will duplicate your error handling since you already have an ExceptionHandler.

Kristoffer E
Yes, the question you linked was one of the many I came across in my research where the question is asked but no clean solution found. I was hoping there was a nicer way, but I agree that a filter or even a wrapper for the resolver might be the only way.
Luke