uploadify_302错误

1、错误原由:

  

  controller类有根据sessionId判断当前是否已经登陆过,当没有sessionId或者sessionId输入的值错误,就会调回登录界面,报出的错误代码为:302

2、查看:可以根据uploadify 的onError方法中的参数:errorObj(type和info),可以查看到对应的错误信息

3、解决方法:将当前的sessionId参数携带到URL中即可:

   script: '/upload.do;jsessionid=<%=session.getId()%'

4、代码:

  

function getUpload() { 
        var buttonImg = $_frontPath+'/images/ny/add.png'; 
        $("#uploadify").uploadify({  
            'uploader'       : '<%=basePath %>/uploadify/scripts/uploadify.swf',
            'script'         : '<%=path %>${ADMIN_URL }/upload/uploadFiles;jsessionid=<%=session.getId()%>',  
            'cancelImg'      : '<%=basePath %>/uploadify/cancel.png',
            'buttonImg'      : buttonImg,  
            'queueID'        : 'fileQueue',  
            'auto'           : true,  
            'multi'          : true,  
            'wmode'          : 'transparent',  
            'simUploadLimit' : 999,  
            'fileExt'        : '*.png;*.gif;*.jpg;*.jpeg',  
            'fileDesc'       : '*.png,*.gif,*.jpg,*.jpeg', 
            'onError': function(e, queueId, fileObj,errorObj){
                alert("类型:" + errorObj.type + "
" +
                      "错误信息:" + errorObj.info + "
" 
                )},    
               
            'onComplete'  :function(event,queueId,fileObj,response,data){
                indx++;
                var retJson = eval(response)[0];
                /*$("#fileUL").append("<li  id='li_"+indx+"'> <img src='<%=path %>"+retJson.filepath+"' style=' 200px;height: 200px;' ></img>"
                +"<input type='hidden' name='borrowPicture' type='text' value='"+retJson.filepath+"' ></input>"
                +"&nbsp;&nbsp;&nbsp;<a href="javaScript:delet('li_"+indx+"')" >删除</a>"
                +"</li>");*/
                
            }  
        }); 
    };
工作小总结,有错请指出,谢谢。
原文地址:https://www.cnblogs.com/zilanghuo/p/5218708.html