利用iframe实现无刷新上传处理

阅读更多
继上一篇对上传异常进行处理之后,当上传异常的时候的错误体验并不是很好,这里介绍用iframe来进行错误提示

拦截错误
	@ExceptionHandler(MaxUploadSizeExceededException.class)         
    public String handleException(Exception ex,HttpServletRequest request,HttpServletResponse response) {       
		try {
         if (ex instanceof org.springframework.web.multipart.MaxUploadSizeExceededException){  
        	 	request.setAttribute("msg", "图片的总计大小不能超过50M ");
         	}
		} catch (Exception e) {
			e.printStackTrace();
		}
//      return "redirect:/sales/apply/onLodaImageUplod.do?mspNo="+mspNo;  
		return "views/sales/apply/a_image_uploading_error";  


控制器
	@RequestMapping(value = "/sales/apply/imageUploding")
	public String imageUploding(String mspNo, HttpServletRequest request,
			HttpServletResponse response , PrintWriter write 
			,@RequestParam("chargeFront") CommonsMultipartFile chargeFront	
			,@RequestParam("applicantIdFront") CommonsMultipartFile applicantIdFront
			,@RequestParam("applicantIdSide") CommonsMultipartFile applicantIdSide
			,@RequestParam("insuredsIdFront") CommonsMultipartFile insuredsIdFront
			,@RequestParam("insuredsIdSide") CommonsMultipartFile insuredsIdSide
			,Model model
			)
	{
               //逻辑处理代码

		return "views/sales/apply/a_image_uploading_error";
	}


a_image_uploading.jsp

下一步



		 $("#imageUploading").click(function() {
			 			document.getElementById('hint').innerHTML = '';
			 		if(checkoutImage()){
			 			var bln = window.confirm("进入自核后,您录入的投保信息以及拍摄的资料将无法再修改,是否继续?");  
			 			document.forms['fm'].target = 'frame';
			 			if(bln){
			 			//showUploadBlock();
			 			//showBlock();
				  		 $("#fm").submit();
			 		}
			 		}
			});


a_image_uploading_error.jsp





${msg}



博客地址:http://qiaoyihang.iteye.com/

你可能感兴趣的:(iframe,无刷新,上传文件)

提示:影像仅支持JPG格式,且单张图片不能超过5M,影像上传过程中,切勿关闭页面,谢谢。
缴费卡照片: ${requestScope.bytesMap['chargeFrontMessage']}