java - How to avoid stacktrace HTTP Status 500 page with MaxUploadSizeExceededException -


i have code (like in spring's reference):

<bean id="multipartresolver"      class="org.springframework.web.multipart.commons.commonsmultipartresolver">         <!-- 1 of properties available; maximum file size in bytes -->         <property name="maxuploadsize" value="100000"/> </bean> 

when user tries upload file on 100 kb server error page http status 500 , stacktrace displayed. how avoid in simplest way? redirect form page , show own error message.

assuming it's org.springframework.web.multipart.maxuploadsizeexceededexception, define error-page in web.xml follows:

<error-page>     <exception-type>org.springframework.web.multipart.maxuploadsizeexceededexception</exception-type>     <location>/upload-error.jsp</location> </error-page> 

note works when don't have <error-page> covers servletexception or 1 of superclasses. otherwise you've bring in exception filter unwraps , rethrows root cause of servletexception.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -