NutzCN Logo
问答 用 WebUploade上传 文件 @Param("file") File file 接收为null
发布于 2171天前 作者 qq_e79520c3 2812 次浏览 复制 上一个帖子 下一个帖子
标签:
    var uploader = WebUploader.create({

        server: '/platform/VideoSystem/uploadFile',
        fileVal:'upload',
        pick:
            {
                multiple: false,
                id: '#excel-upload'
            },
        accept:{
             extensions: 'xls',
        },
        formData: {
            uid: 123
        },
        threads: 1,
    });
    //当有文件添加进来的时候
    uploader.on('fileQueued', function (file) {
        //具体逻辑根据项目需求来写  这里只是简单的举个例子写下
        $one = $("<div >"+file.name+"</div>"+"<buttom id = 'btnClick'> 上传 </buttom>");
        $("#excel-upload").append($one);
    });
    // 文件上传过程中创建进度条实时显示。
    uploader.on('uploadProgress', function (file, percentage) {
        // 具体逻辑...
    });
    // 文件上传成功处理。
    uploader.on('uploadSuccess', function (file, response) {
        // 具体逻辑...
        console.log('upload success...\n');
    });
    // 文件上传失败处理。
    uploader.on('uploadError', function (file) {
        // 具体逻辑...
    });
    // 上传传完毕,不管成功失败都会调用该事件,主要用于关闭进度条
    uploader.on('uploadComplete', function (file) {
        // 具体逻辑...
    });
    //点击上传按钮触发事件
    $("body").on('click','#btnClick',function(){
        uploader.upload();
    });

----------------------------------------------

    @At("/uploadFile")
    @AdaptBy(type = UploadAdaptor.class, args = { "ioc:myExcelUpload" })
    public void uploadPhoto(@Param("uid") int uid , @Param("file") File file){
            System.out.println("aaa");
    }
}

3 回复
[DEBUG] 2019-01-11 14:53:10,633 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) - Get 'shiroUtil'<class cn.wizzer.framework.util.ShiroUtil>
[DEBUG] 2019-01-11 14:53:10,633 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) - Get 'dateUtil'<class cn.wizzer.framework.util.DateUtil>
[DEBUG] 2019-01-11 14:53:10,633 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) - Get 'stringUtil'<class cn.wizzer.framework.util.StringUtil>
[DEBUG] 2019-01-11 14:53:10,633 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) - Get 'videoController'<class cn.wizzer.app.web.modules.controllers.platform.VideoSystem.VideoController>
[DEBUG] 2019-01-11 14:53:10,634 org.nutz.mvc.upload.UploadAdaptor.getReferObject(UploadAdaptor.java:184) - Select Html4 Form upload parser --> /platform/VideoSystem/uploadFile
[DEBUG] 2019-01-11 14:53:10,654 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:39) - FastUpload : /platform/VideoSystem/uploadFile
[DEBUG] 2019-01-11 14:53:10,661 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:54) - info created
[DEBUG] 2019-01-11 14:53:10,661 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:60) - Params map created - 0 params
[DEBUG] 2019-01-11 14:53:10,665 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:77) - boundary: 
------WebKitFormBoundaryB9mAbldqc18JFFi9
[DEBUG] 2019-01-11 14:53:10,678 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:100) - skip first boundary
[DEBUG] 2019-01-11 14:53:10,679 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:111) - Reading...
[DEBUG] 2019-01-11 14:53:10,682 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) - Upload File info: FilePath=[null],fieldName=[uid]
[DEBUG] 2019-01-11 14:53:10,683 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) - Found a param, name=[uid] value=[123]
[DEBUG] 2019-01-11 14:53:10,684 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) - Upload File info: FilePath=[null],fieldName=[id]
[DEBUG] 2019-01-11 14:53:10,684 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) - Found a param, name=[id] value=[WU_FILE_0]
[DEBUG] 2019-01-11 14:53:10,684 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) - Upload File info: FilePath=[null],fieldName=[name]
[DEBUG] 2019-01-11 14:53:10,684 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) - Found a param, name=[name] value=[视频点位批量录入模板 (1).xls]
[DEBUG] 2019-01-11 14:53:10,685 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) - Upload File info: FilePath=[null],fieldName=[type]
[DEBUG] 2019-01-11 14:53:10,685 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) - Found a param, name=[type] value=[application/vnd.ms-excel]
[DEBUG] 2019-01-11 14:53:10,685 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) - Upload File info: FilePath=[null],fieldName=[lastModifiedDate]
[DEBUG] 2019-01-11 14:53:10,685 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) - Found a param, name=[lastModifiedDate] value=[Thu Jan 10 2019 18:48:29 GMT+0800 (中国标准时间)]
[DEBUG] 2019-01-11 14:53:10,685 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) - Upload File info: FilePath=[null],fieldName=[size]
[DEBUG] 2019-01-11 14:53:10,686 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) - Found a param, name=[size] value=[13824]
[DEBUG] 2019-01-11 14:53:10,686 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) - Upload File info: FilePath=[视频点位批量录入模板 (1).xls],fieldName=[upload]
[DEBUG] 2019-01-11 14:53:10,687 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:137) - Upload Info: name=视频点位批量录入模板 (1).xls,content_type=application/vnd.ms-excel
[DEBUG] 2019-01-11 14:53:10,698 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:231) - ...Done 14740 bytes readed

日志里面显示文件的字段名叫upload,而非file

突然发现了,谢谢兽总~~

添加回复
请先登陆
回到顶部