Announcement Announcement Module
No announcement yet.
How to handle SizeLimitExceededException from CommonsMultipartResolver in SWF ? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to handle SizeLimitExceededException from CommonsMultipartResolver in SWF ?

    Hello all!

    I have the following situation. I have a CommonsMultipartResolver bean configured the following way.

      <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="2100000" />
    And I have a few file upload fields in a Spring Web Flow view state jsp.

    Everything works fine if the file is under the limit, but if the file exceeds the limit of 2MB-s I have to add a validation error to the binding result on my form.

    My problem is that the multipart file resolver throws a org.apache.commons.fileupload.FileUploadBase.SizeL imitExceededException exception when the file limit is exceeded and I can't find a way to catch this in Spring Web Flow and add my FieldError to the form.

    I tried using the on-exception attribute of the transition tag, but if I understand correctly it only works for exceptions that are thrown within Spring Web Flow.

    I've also tried to use SimpleMappingExceptionResolver in spring mvc, but I do not want to redirect to a page, I want to handle this exception.

    I also found this:

    But it's from version 1.0 and I'm assuming that this has been incorporated since or that a better way was found to handle these situations.

    Any ideas on how to deal with this would be greatly appreciated.