关于android内置微信浏览器,10秒自动重复提交的大坑,简单出爆,干掉他

先说说这个机制问题,10秒超时,微信浏览器会自动使用代理进行提交,并且会打断第一次提交,如果你是订单的话,你就只能呵呵了。

我就是有个功能,上传一堆的附件到oss去,结果超过10s了,你会发现时间越来越久,原来微信给你再次提交,订单直接报id错误。

移动端的ie6,不想说什么了,直接贴代码:

 /**
     * 保存车辆申请记录
     */
    @CheckLogin
    @Certification
    @RequestMapping(value="/saveApply",method=RequestMethod.POST)
    public void saveApply(
            LoanApplicationRecord loanApplicationRecord
            ,@RequestParam String CAR_POSITIVE
            ,@RequestParam String CAR_BACK
            ,@RequestParam String CAR_LEFT
            ,@RequestParam String CAR_RIGHT
            ,@RequestParam String ENGINE_NAMEPLATE
            ,@RequestParam String VEHICLE_REGISTRATION_FRONT
            ,@RequestParam String VEHICLE_REGISTRATION_BACK
            ,@RequestParam String DRIVING_PERMIT
            ,@RequestParam String VEHICLE_PURCHASE_CONTRACT
            ,String LOAN_FILE_OTHER
            ,HttpServletRequest request
            ,HttpServletResponse response){
        ResultVO rv =  ResultVO.getFailInstance();
        try {
            /**
             * 开始保存申请记录
             */
            loanApplicationRecordService.submit(getSessionUserID(request)
                    ,loanApplicationRecord);
            // 登录成功
            rv.setSuccess();
        }catch(BusinessRuntimeException e){
            rv.setMsg(e.getMessage());
        }catch (Exception e) {
            // 未知异常,打印日志,返回系统错误
            LogUtils.error(e.getMessage());
            rv.setSysError();
        }
        try{

  // 重点就是在这里........   直接保存记录返回结果,够简单粗暴吧,

  //前提是你要保证下面的代码没啥问题,反正我是没法保证了。

  //反正就几个文件,大不了重新叫他上传吧。哈哈

            response.getWriter().print(rv.toJson());
            response.getWriter().flush();
            response.getWriter().close();




//  这里就不管能不能成功了。这么多文件,管他呢,我只能说,秒传,what the fuck ...WX
            
            // 这里进行文件的上传,时间过长,故先返回结果。
            String basePath = request.getServletContext().getRealPath("/");
            Long userId = getSessionUserID(request);
            User user = getSessionUserByDB(request);
    
            loanApplicationAttachmentService.insert(basePath, CAR_POSITIVE,
                    FileTypeEnum.APPLY_LOAN.getPath() + userId + "/", user,
                    loanApplicationRecord, LoanFileTypeEnum.CAR_POSITIVE);
            loanApplicationAttachmentService.insert(basePath, CAR_BACK,
                    FileTypeEnum.APPLY_LOAN.getPath() + userId + "/", user,
                    loanApplicationRecord, LoanFileTypeEnum.CAR_BACK);
            loanApplicationAttachmentService.insert(basePath, CAR_LEFT,
                    FileTypeEnum.APPLY_LOAN.getPath() + userId + "/", user,
                    loanApplicationRecord, LoanFileTypeEnum.CAR_LEFT);
            loanApplicationAttachmentService.insert(basePath, CAR_RIGHT,
                    FileTypeEnum.APPLY_LOAN.getPath() + userId + "/", user,
                    loanApplicationRecord, LoanFileTypeEnum.CAR_RIGHT);
            loanApplicationAttachmentService.insert(basePath, ENGINE_NAMEPLATE,
                    FileTypeEnum.APPLY_LOAN.getPath() + userId + "/", user,
                    loanApplicationRecord, LoanFileTypeEnum.ENGINE_NAMEPLATE);
            loanApplicationAttachmentService.insert(basePath,
                    VEHICLE_REGISTRATION_FRONT, FileTypeEnum.APPLY_LOAN.getPath()
                            + userId + "/", user, loanApplicationRecord,
                    LoanFileTypeEnum.VEHICLE_REGISTRATION_FRONT);
            loanApplicationAttachmentService.insert(basePath,
                    VEHICLE_REGISTRATION_BACK, FileTypeEnum.APPLY_LOAN.getPath()
                            + userId + "/", user, loanApplicationRecord,
                    LoanFileTypeEnum.VEHICLE_REGISTRATION_BACK);
            loanApplicationAttachmentService.insert(basePath, DRIVING_PERMIT,
                    FileTypeEnum.APPLY_LOAN.getPath() + userId + "/", user,
                    loanApplicationRecord, LoanFileTypeEnum.DRIVING_PERMIT);
            loanApplicationAttachmentService.insert(basePath,
                    VEHICLE_PURCHASE_CONTRACT, FileTypeEnum.APPLY_LOAN.getPath()
                            + userId + "/", user, loanApplicationRecord,
                    LoanFileTypeEnum.VEHICLE_PURCHASE_CONTRACT);
            loanApplicationAttachmentService.insert(basePath, LOAN_FILE_OTHER,
                    FileTypeEnum.APPLY_LOAN.getPath() + userId + "/", user,
                    loanApplicationRecord, LoanFileTypeEnum.LOAN_FILE_OTHER);
        }catch(Exception e){
            
        }
        
    }

你可能感兴趣的:(关于android内置微信浏览器,10秒自动重复提交的大坑,简单出爆,干掉他)