- Spring Framework: 1.x
- Sitemesh: 2.2.1
Given the following multipartResolver in my spring servlet xml config file:
1.) servlet-xml file
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize"> <value>20000</value> </property> <property name="maxInMemorySize"> <value>0</value> </property> </bean>
2.) A multi-part form page that uploads a file.
3.) One or more sitemesh decorators applied to the page (1 main decorator and a few inline decorators).
Upon submitting the form, the request goes to the DispatcherServlet and calls the checkMultipart(request) method. If the size of the file being uploaded exceeds the max, a MultipartException gets thrown but does not get propagated. Spring tries to resolve the view assigned to this exception mapped with SimpleMappingExceptionResolver. The implication to this is that all pages being decorated by sitemesh are showing the default error page assigned.
So if a decorator is used on the menu, header, sidebar, and body of the page then the user will see 4 exception pages.
I've created a workaround for this by extending the DispatcherServlet and overloading the processHandlerException(...) method to rethrow any exceptions of type MultipartException (and not try to resolve the exception page assigned in spring).
No comments:
Post a Comment