Hi,
I know its hard to check the file size at the client side(browser) with just pure javascript only.
Now, my question is, Is there a way at the server side to catch an exception such as this?
org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size of 2000000 bytes
What happens is that, it does not reach my @controller post method and it just throws up the exception that is being catch up by my error.jsp.
What I was thinking is that, is it possible to do this in spring mvc annotated method?
@RequestMapping("/uploadFile.htm")
public String uploadAttachment(
HttpServletRequest request,
@RequestParam(required = false, value = "attached-file") MultipartFile file,
ModelMap model) throws Exception {
if(checkfilesize(file)){
//populate model
//add error if appplicable
//return same form again
}
//return success
}
}
My problem is, it doesnt reaches upto this point and just throw up a big fat exception.
Although the error.jsp was able to catch it, I would think its much user friendly if I can alert the user that the file they are about to upload exceeds the limit.
This is Spring MVC 2.5 app by the way. Is this possible?