Announcement Announcement Module
Collapse
No announcement yet.
Uploading files with a maxUploadSize limit Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Uploading files with a maxUploadSize limit

    My application allows users to upload a file up to 5mbytes. Everything works great. The big problem is the user gets an ugly stack trace if they try and upload a >5mbyte file. Obviously that's not acceptable.

    How do I present the user with something more meaningful? Do I just change the error page in Tomcat? But I want the user to know what the problem was! Is there no solution and Spring's file upload mechanism is simply unusable?? That would suck... but searching these forums and perusing the documentation and javadocs haven't produced anything for me.

    I guess worst case scenario is to not set the maxUploadSize, defaulting to unlimited, and check within my application. But presumably I'd lose the efficiency of checking the upload's headers to avoid downloading a huge file.

  • #2
    you've got an exception.
    you can "catch" it.
    add to yourapplication-servlet.xml this
    Code:
        <!-- ================================== Exception resolver ==================================-->    
    <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
          <property name="exceptionMappings">
                    <props>
                              <prop key="org.springframework.web.multipart.MaxUploadSizeExceededException">uploadError</prop>
                    </props>
          </property>
    </bean>
    and don't forget to add uploadError.jsp to your application. In uploadError.jsp put user-friendly error message.

    Comment


    • #3
      Thank you kolo!! Works perfect

      Comment

      Working...
      X