如何捕获上传文件过大的的异常
使用com.jspsmart.upload上传图片,如何能捕获图片过大的异常
SmartUpload su=new SmartUpload();
su.initialize(pageContext);
su.setTotalMaxFileSize(1024*1024);
su.setAllowedFilesList( "JPG,jpg,bmp,BMP,gif,GIF ");
su.upload();
------解决方案--------------------SmartUpload su=new SmartUpload();
su.initialize(pageContext);
su.setAllowedFilesList( "JPG,jpg,bmp,BMP,gif,GIF ");
su.setTotalMaxFileSize(1024*1024);
try{
su.upload();
} catch(
SecurityException e) {
if (e.getMessage().indexOf( "1110 ") > 0 || e.getMessage().indexOf( "1105 ") > 0) {
out.print( "文件的大小超过了1M! ");
}else {
out.print( "e.getMessage() ");
}
return;
}